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:

    In order to succeed in a profession, a person not only needs to have its good, but also its bad qualities. The former are the spirit, the latter is the body of the job.
    Franz Grillparzer (1791–1872)

    I am gradually drifting to the opinion that this Rebellion can only be crushed finally by either the execution of all the traitors or the abolition of slavery. Crushed, I mean, so as to remove all danger of its breaking out again in the future.
    Rutherford Birchard Hayes (1822–1893)