Find difference between sum of all nodes present at odd and even levels in a binary tree
Given a binary tree, calculate the difference between the sum of all nodes present at odd levels and the sum of all nodes present at even level.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven a binary tree, calculate the difference between the sum of all nodes present at odd levels and the sum of all nodes present at even level.
Given a binary tree, print its nodes in vertical order. Assume that the left and right child of a node makes a 45–degree angle with the parent.
Given a binary tree, write an efficient algorithm to link nodes at the same level in the form of a linked list like structure.
Write an efficient algorithm to find a binary tree’s preorder traversal from its inorder and postorder sequence without constructing the tree.
Given a binary tree, count all subtrees in it such that every node in the subtree has the same value.
Given a BST, find the inorder successor of a given key in it. If the given key does not lie in the BST, then return the next greater key (if any) present in the BST.
Given a binary tree, write an efficient algorithm to find the maximum sum path between any two leaves in it.
Given a binary tree, write an efficient algorithm to find all nodes present at a given distance from any leaf node. We need to find only those nodes that are present in the root-to-leaf path for that leaf.
Given a binary tree that is only one swap away from becoming a BST, convert it into a BST in a single traversal.
Given a binary tree, find the maximum difference between a node and its descendants in it.
Given a binary tree, efficiently clone of it.
Given a binary tree, write an efficient algorithm to print its right view. For example, the right view of a given binary tree is 1, 3, 6, 8.