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:

    Man is clearly made to think. It is his whole dignity and his whole merit; and his whole duty is to think as he ought. And the order of thought is to begin with ourselves, and with our Author and our end.
    Blaise Pascal (1623–1662)

    However, the danger in [socially unbalanced relationships] is that the subjection of the woman temporarily calms the man’s jealousy but also renders it more demanding. He ends up making his mistress live like those prisoners on whom light is shone day and night in order for them to be better watched. And things always end in tragedy.
    Marcel Proust (1871–1922)

    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)