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:

    The principles of the good society call for a concern with an order of being—which cannot be proved existentially to the sense organs—where it matters supremely that the human person is inviolable, that reason shall regulate the will, that truth shall prevail over error.
    Walter Lippmann (1889–1974)

    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 I were asked to chose between execution and life in prison I would, of course, chose the latter. It’s better to live somehow than not at all.
    Anton Pavlovich Chekhov (1860–1904)