Recursive Call - Order of Execution

Order of Execution

In a recursive function, the position in which additional statements (i.e., statements other than the recursive call itself) are placed is important. In the simple case of a function calling itself only once, a statement placed before the recursive call will be executed first in the outermost stack frame, while a statement placed after the recursive call will be executed first in the innermost stack frame. Consider this example:

Read more about this topic:  Recursive Call

Famous quotes containing the words order of, order and/or execution:

    ““New order of the ages” did we say?
    If it looks none too orderly today,
    ‘Tis a confusion it was ours to start
    So in it have to take courageous part.”
    —Robert Frost (1874–1963)

    “I suppose that one of the psychological principles of advertising is to so hammer the name of your product into the mind of the timid buyer that when he is confronted with a brusk demand for an order he can’t think of anything else to say, whether he wants it or not.”
    —Robert Benchley (1889–1945)

    “Union of Religious Sentiments begets a surprising confidence and Ecclesiastical Establishments tend to great ignorance and corruption, all of which facilitate the Execution of Mischievous Projects.”
    —James Madison (1751–1836)