# What is the non recursive algorithm for Postorder traversal of a binary tree?

## What is the non recursive algorithm for Postorder traversal of a binary tree?

1) Algorithm for Postorder POSTORD(INFO, LEFT, RIGHT, ROOT) Step-1 [Push NULL onto STACK and initialize PTR] Set TOP=1, STACK[1]=NULL and PTR=ROOT. Step-2 [Push left-most path onto STACK] repeat step 3 to 5 while PTR not equal NULL. Step-3 set TOP=TOP+1 and STACK[TOP]=PTR. [Pushes PTR on STACK].

## How many stack S is are required to perform non recursive post order traversal of a binary tree?

two stacks
Here is a solution in C++ that does not require any storage for book keeping in the tree. Instead it uses two stacks. One to help us traverse and another to store the nodes so we can do a post traversal of them.

What is Postorder traversal for the given tree?

Postorder traversal is used to delete the tree. Please see the question for deletion of tree for details. Postorder traversal is also useful to get the postfix expression of an expression tree.

What is the pre-order traversal of a binary tree?

Binary Tree Traversals In pre-order traversal, each node is processed before (pre) either of its sub-trees. This is the simplest traversal to understand. However, even though each node is processed before the sub-trees, it still requires that some information must be maintained while moving down the tree.

### What is in-order traversal?

in-order traversal. Definition: Process all nodes of a tree by recursively processing the left subtree, then processing the root, and finally the right subtree. Also known as symmetric traversal.

### Do in-order traversal of tree?

The InOrder traversal is one of the three popular ways to traverse a binary tree data structure, the other two being the preOrder and postOrder. During the in-order traversal algorithm, the left subtree is explored first, followed by root, and finally nodes on the right subtree.

What does tree traversal mean?

In computer science, tree traversal (also known as tree search) is a form of graph traversal and refers to the process of visiting (checking and/or updating) each node in a tree data structure, exactly once. Such traversals are classified by the order in which the nodes are visited.