...
/Solution Review: Print Depth First Without Using the Recursion
Solution Review: Print Depth First Without Using the Recursion
Let’s go through the detailed solution review of the challenge given in the previous lesson.
We'll cover the following...
We'll cover the following...
Solution
Typically, the depth-first traversal of a tree is done by using the system stack recursion. However, the same can be implemented by using a stack data structure as well. The following code demonstrates the latter approach. In the beginning, root node reference is added to the stack. The whole tree is traversed ...