##
Find the Deepest Node in a Binary Tree
March 25, 2017

Given a binary tree, find the deepest node in it. Examples: Input : Root of below tree 1 / \ 2 3 / \ /… Read More »

March 25, 2017

Given a binary tree, find the deepest node in it. Examples: Input : Root of below tree 1 / \ 2 3 / \ /… Read More »

March 20, 2017

Given an undirected tree which has even number of vertices, we need to remove the maximum number of edges from this tree such that each… Read More »

March 11, 2017

Given a binary tree, print the root to the leaf path, but add “_” to indicate the relative position. Example: Input : Root of below… Read More »

March 6, 2017

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 »

March 5, 2017

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 »

February 23, 2017

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 »

February 14, 2017

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

February 13, 2017

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 »

February 10, 2017

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

February 7, 2017

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 »

February 5, 2017

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

February 3, 2017

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 »

January 28, 2017

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 »

January 27, 2017

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 »