## Check if a Binary Tree contains duplicate subtrees of size 2 or more

Given a Binary Tree, check whether the Binary tree contains a duplicate sub-tree of size 2 or more. Note : Two same leaf nodes are… Read More »

Quick Links for Tree

Quizzes |

Given a Binary Tree, check whether the Binary tree contains a duplicate sub-tree of size 2 or more. Note : Two same leaf nodes are… Read More »

Given an undirected tree, we need to find the longest path of this tree where a path is defined as a sequence of nodes. Example:… Read More »

We have seen various methods with different Time Complexities to calculate LCA in n-ary tree:- Method 1 : Naive Method ( by calculating root to… Read More »

Idea of Threaded Binary Tree is to make inorder traversal faster and do it without stack and without recursion.

A ScapeGoat tree is a self-balancing Binary Search Tree like AVL Tree, Red-Black Tree, Splay Tree, ..etc. Search time is O(Log n) in worst case.… Read More »

Prerequisite : Segment Tree Persistency in Data Structure Segment Tree is itself a great data structure that comes into play in many cases. In this… Read More »

Prerequisite : Introduction and DFS The task is to find LCA of two given nodes in a tree (not necessarily a Binary Tree). In previous… Read More »

Given a binary tree, print it vertically. The following example illustrates vertical order traversal. 1 / \ 2 3 / \ / \ 4 5… Read More »

A binary tree and a number k are given. Print every path in the tree with sum of the nodes in the path as k.… Read More »

Given a tree of n even nodes. The task is to find the maximum number of edges to be removed from the given tree to… Read More »

Given the array representation of Complete Binary Tree i.e, if index i is the parent, index 2*i + 1 is the left child and index… Read More »

The diameter of an N-ary tree is the longest path present between any two nodes of the tree. These two nodes must be two leaf… Read More »

Given an N-Ary tree, find depth of the tree. An N-Ary tree is a tree in which nodes can have at most N children. Examples:… Read More »

Given a Binary tree and a sum S, print all the paths, starting from root, that sums upto the given sum. Note that this problem… Read More »

In previous posts, we have discussed how to calculate the Lowest Common Ancestor (LCA) for a binary tree and a binary search tree (this, this… Read More »