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)

    Kicking his mother until she let go of his soul
    Has given his a healthy appetite: clearly, her role
    In the New Order must be
    To supply and deliver his raw materials free;
    —W.H. (Wystan Hugh)

    The application requisite to the duties of the office I hold [governor of Virginia] is so excessive, and the execution of them after all so imperfect, that I have determined to retire from it at the close of the present campaign.
    Thomas Jefferson (1743–1826)