Implementation of recursive calls

- Static Vs Dynamic allocation of activation records

Whenever a procedure is called, all the relevant information about the procedure such as program counter, values of a variables/registers is stored in an activation record.

- Static: Fortran. Only one copy of activation record.

- Dynamic: Algol-like languages.

- Activation records are created at the time of the call to subprogram.

- There is new instantiation of all the local variables.

- Maintained on the stack.

- Stack is ideal for such things.

factorial(5)

|

factorial(4)

|

factorial(3)

|

factorial(2)

|

factorial(1)

Tower of Hanoi