Understanding the problem
The recursive tree traversal algorithms we learned earlier in the course are quite easy and can be implemented neatly. However, they all have a major limitation: They rely on recursive function calls, which rely on stack memory.
Call stack
Let us revisit how function calls work for a computer program. All computer programs have stack memory available to manage function calls. Whenever a function call is made in the program, a stack frame with all the information related to that function (local variables, return address, etc.) is created and pushed on top of the stack. When the function execution finishes and the control returns to the caller, this stack frame is destroyed by a stack pop operation.
Liking the course? Check our discounted plans to continue learning.