For example, in the Tower of Hanoi puzzle, the user may want to interrupt the demonstration being eager to test his or her understanding of the solution. There are complications due to the manner in which computers execute programs when one wishes to jump out of several levels of recursive calls. Recursive implementation easily got around this difficulty. With each invocation of the Conversion function, computer creates a new environment in which passed values of M, N, and the newly computed S are stored. Completing the function call, i.e. returning from the function we find the environment as it was before the call.
Recursive functions store a sequence of computations implicitly.
Eliminating recursive calls implies that we must manage to store the computed digits explicitly and then retrieve them in the reversed order. In Computer Science such a mechanism is known as LIFO - Last In First Out. It's best implemented with a stack data structure . Intuitively stack can be visualized as indeed a stack of objects. Objects are stacked on top of each other so that to retrieve an object one has to remove all the objects above the needed one.