Recursion (computer Science) - 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:  Recursion (computer Science)

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

    “It is well within the order of things
    That man should listen when his mate sings;
    But the true male never yet walked
    Who liked to listen when his mate talked.”
    —Anna Wickham (1884–1947)

    “In schools all over the world, little boys learn that their country is the greatest in the world, and the highest honor that could befall them would be to defend it heroically someday. The fact that empathy has traditionally been conditioned out of boys facilitates their obedience to leaders who order them to kill strangers.”
    —Myriam Miedzian, U.S. author. Boys Will Be Boys, ch. 3 (1991)

    “If Germany is to become a colonising power, all I say is, “God speed her!” She becomes our ally and partner in the execution of the great purposes of Providence for the advantage of mankind.”
    —W.E. (William Ewart)