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:

    “In the order of literature, as in others, there is no act that is not the coronation of an infinite series of causes and the source of an infinite series of effects.”
    —Jorge Luis Borges (1899–1986)

    “He had discovered a great law of human action, without knowing it—namely, that in order to make a man or a boy covet a thing, it is only necessary to make the thing difficult to attain. If he had been a great and wise philosopher, like the writer of this book, he would now have comprehended that Work consists of whatever a body is obliged to do and that Play consists of whatever a body is not obliged to do.”
    —Mark Twain [Samuel Langhorne Clemens] (1835–1910)

    “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)