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:

    “The world men inhabit ... is rather bleak. It is a world full of doubt and confusion, where vulnerability must be hidden, not shared; where competition, not co-operation, is the order of the day; where men sacrifice the possibility of knowing their own children and sharing in their upbringing, for the sake of a job they may have chosen by chance, which may not suit them and which in many cases dominates their lives to the exclusion of much else.”
    —Anna Ford (b. 1943)

    “The comic spirit is given to us in order that we may analyze, weigh, and clarify things in us which nettle us, or which we are outgrowing, or trying to reshape.”
    —Thornton Wilder (1897–1975)

    “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)