InterviewSolution
Saved Bookmarks
| 1. |
Write a short note on the non-recursive tree traversals using stack. |
| Answer» 1) CREATE an empty stack S. 2) Initialize CURRENT node as ROOT 3) Push the current node to S and set current = current->left until current is NULL 4) If current is NULL and stack is not empty then a) Pop the top item from stack. b) Print the popped item, set current = popped_item->right c) Go to step 3. 5) If current is NULL and stack is empty then we are done. | |