Using Stack is the obvious way to traverse tree without recursion. Below is an algorithm for traversing binary tree using stack. See this for step wise step execu...

Share

Using Morris Traversal, we can traverse the tree without using stack and recursion. The idea of Morris Traversal is based on Threaded Binary Tree. In this traversal,...

Share

Given Inorder and Preorder traversals of a binary tree, print Postorder traversal.
Example:
Input:
Inorder traversal in[] = {4, 2, 5, 1, 3, 6}
Preorder traversal pre[...

Share

Given an array representing preorder traversal of BST, print its postorder traversal.
Examples:
Input : 40 30 35 80 100
Output : 35 30 100 80 40
Input : 40 30 32 35...

Share

Given an array that represents Inorder Traversal, find all possible Binary Trees with the given Inorder traversal and print their preorder traversals.
Examples:
Input...

Share

Given the binary tree and you have to find out the n-th node of inorder traversal.
Examples:
Input : n = 4
10
/
20 30
...

Share

Given a Binary tree and a number N, write a program to find the N-th node in the Postorder traversal of the given Binary tree.
Prerequisite: Tree Traversal
Examples:
...

Share

Given a binary tree, print the level order traversal in such a way that first two levels are printed from left to right, next two levels are printed from right to lef...

Share

Given a Binary Tree, print the nodes level wise, each level on a new line.
Output:
1
2 3
4 5
Recommended: Please solve it on “PRACTICE” first, before...

Share

We have discussed level order traversal of a post in previous post. The idea is to print last level first, then second last level, and so on. Like Level order travers...

Share