Given a Binary Tree, check if all leaves are at same level or not.
Given Inorder and Preorder traversals of a binary tree, print Postorder traversal.
The length of left or right tree is same in both in-order or preorder.
// Prints postorder traversal from given inorder and preorder traversalsvoid printPostOrder(int in[], int pre[], int n){ // The first element in pre[] is always root, search it // in in[] to find left and right subtrees int root = search(in, pre[0], n); // If left subtree is not empty, print left subtree if (root != 0) printPostOrder(in, pre+1, root); // If right subtree is not empty, print right subtree if (root != n-1) printPostOrder(in+root+1, pre+root+1, n-root-1); // Print root cout << pre[0] << " ";}