Level-wise traversal of a binary tree

Write an Algorithm to print the elements of a binary tree in level-wise order. For example if the Binary tree is as given below: Then the traversal should be in the following order:

Making tree from traversals

Given the pre-order and in-order traversal of a Binary Tree. Construct the tree from these traversals. InOrder: 1 4 5 8 10 30 40 PreOrder: 10 5 4 1 8 30 40 Can you construct the Tree if only post-order and in-order traversals are given? Can you construct a tree if only pre-order and post-order […]

Basic Tree Traversals (Preorder, Inorder, Postorder)

If the node of a Binary tree is defined as below: struct Node{ Node * lptr; // Pointer to Left subtree int data; Node *rptr; // Pointer to Right subtree }; write functions which will traverse the tree in in-Order, Pre-Order and Post-Order.