Question 1 Non Recursive Order Traverse Binary Tree Using Stack Obvious Way Traverse Tree Q37028837

Question 1: Non-recursive In-order traverse of a binary treeUsing Stack is the obvious way to traverse tree without recursion.Below is an algorithm for traversing binary tree using stack. Seethis for step wise step execution of the algorithm. 1) Create anempty stack S. 2) Initialize current node as root 3) Push thecurrent node to S and set current = current->left until currentis NULL 4) If current is NULL and stack is not empty then a) Popthe top item from stack. b) Print the popped item, set current =popped_item->right c) Go to step 3. 5) If current is NULL andstack is empty

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.