## Lowest Common Ancestor in a Binary Tree | Set 3 (Using RMQ)

Given a rooted tree, and two nodes which is in the tree, find the Lowest common ancestor of both the nodes. The LCA for two… Read More »

Quick Links for Tree

Quizzes |

Given a rooted tree, and two nodes which is in the tree, find the Lowest common ancestor of both the nodes. The LCA for two… Read More »

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… Read More »

Given inorder and level-order traversals of a Binary Tree, construct the Binary Tree. Following is an example to illustrate the problem. Examples: Input: Two arrays… Read More »

We have a simple binary tree and we have to print the top 3 largest elements present in the binary tree. Examples: Input : 1… Read More »

AVL tree is binary search tree with additional property that difference between height of left sub-tree and right sub-tree of any node can’t be more… Read More »

Size of a tree is the number of elements present in the tree. Size of the below tree is 5.

Given a tree, print the level order traversal in sorted order. Examples : Input : 7 / \ 6 5 / \ / \ 4… Read More »

Given a binary tree. Modify it in such a way that after modification you can have a preorder traversal of it using only the right… Read More »

Given Preorder traversal of a Binary Search Tree. Then the task is print leaf nodes of the Binary Search Tree from the given preorder. Examples:… Read More »

Given a binary tree containing n nodes. The problem is to find the maximum sum obtained when the tree is spirally traversed. In spiral traversal… Read More »

Given a Binary tree, the task is to print its all level in sorted order Examples: Input : 7 / \ 6 5 / \… Read More »

Given a binary tree containing n nodes. The problem is to find and print the largest value present in each level. Examples: Input : 1… Read More »

Given a binary tree, find the largest value in each level. Examples : Input : 1 / \ 2 3 Output : 1 3 Input… Read More »

Check if a Binary Tree (not BST) has duplicate values Examples: Input : Root of below tree 1 / \ 2 3 \ 2 Output… Read More »

We are given a tree of size n as array parent[0..n-1] where every index i in parent[] represents a node and the value at i… Read More »