## How do you implement inorder traversal without using recursion?

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.

**Which traversal of tree does not use stack?**

Morris (InOrder) traversal is a tree traversal algorithm that does not employ the use of recursion or a stack. In this traversal, links are created as successors and nodes are printed using these links. Finally, the changes are reverted back to restore the original tree.

### Can we design tree traversal without recursion?

yes, you can do it with stack. you have to take stack here the algorithm for p reorder, in-order and post-order traversal in iterative way (non recursive way/method) of binary search tree.

**Which data structure is used for non recursive traversal?**

Using Stack is the obvious way to traverse tree without recursion.

#### What is recursive and non recursive tree traversing?

Recursive functions are simpler to implement since you only have to care about a node, they use the stack to store the state for each call. Non-recursive functions have a lot less stack usage but require you to store a list of all nodes for each level and can be far more complex than recursive functions.

**How do you create a binary tree without recursion?**

Pre-order traversal in Java without recursion

- Create an empty stack.
- Push the root into Stack.
- Loop until Stack is empty.
- Pop the last node and print its value.
- Push right and left node if they are not null.
- Repeat from steps 4 to 6 again.

## Which of the following is not the application of stack?

Which of the following is not an inherent application of stack? Explanation: Job Scheduling is not performed using stacks.

**Which of the following algorithm Cannot be designed without recursion?**

Discussion Forum

Que. | Which of the following algorithm cannot be designed without recursion? |
---|---|

b. | Fibonacci Series |

c. | Tree Traversal |

d. | All can be designed without recursion |

Answer:All can be designed without recursion |

### What is non-recursive preorder traversal?

Since we are not using recursion, we will use the Stack to store the traversal, we need to remember that preorder traversal is, first traverse the root node then left node followed by the right node. Pseudo Code: Create a Stack. Print the root and push it to Stack and go left i.e root=root.

**What is non-recursive algorithm?**

A non-recursive algorithm does the sorting all at once, without calling itself. Bubble-sort is an example of a non-recursive algorithm.

#### What is the difference between recursive and non-recursive function?

Recursive function is a function which calls itself again and again. A recursive function in general has an extremely high time complexity while a non-recursive one does not.