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 and/or execution:

    Deafness produces bizarre effects, reversing the natural order of things; the interchange of letters is the conversation of the deaf, and the only link with society. I would be in despair, for instance, over seeing you speak, but, instead, I am only too happy to hear you write.
    Philip Dormer Stanhope, 4th Earl Chesterfield (1694–1773)

    My weakness has always been to prefer the large intention of an unskilful artist to the trivial intention of an accomplished one: in other words, I am more interested in the high ideas of a feeble executant than in the high execution of a feeble thinker.
    Thomas Hardy (1840–1928)