Category Archives: Tree

Given a binary tree, the task is to find the length of the longest path which forms an Arithmetic progression. The path can start and… Read More
Given a Binary Tree rooted at root, the task is to find the sum of all leaf nodes which are left child of their parents… Read More
Given a binary tree, print it vertically.  NOTE: If there are multiple nodes at the same point, then print them in sorted order. Examples: Input:… Read More
Pre-requisite: Maximum width of a Binary Tree with null value | Set 1 Given a Binary Tree consisting of N nodes, the task is to… Read More
Given an N-array tree root and an integer K, the task is to print all the cousins of node K. Note: Two nodes are considererd… Read More
Given a tree of N nodes and an integer K, the task is to find the total number of paths having length K. Examples: Input:… Read More
What is Height Balanced Tree? Self-Balancing binary search trees are the height-balanced binary tree is one for which at every node, the absolute value of… Read More
Given an array arr, the task is to replace each array element by the maximum of K next and K previous elements. Example: Input: arr[]… Read More
Given an unsorted vector arr, the task is to create a balanced binary search tree using the elements of the array. Note: There can be… Read More
Given a Binary Tree consisting of N nodes and two positive integers L and R, the task is to find the count of nodes having… Read More
For every node in an undirected tree, find the sum of length of paths from it to all other nodes, using Tree Rerooting technique. Rerooting… Read More
Given an N-ary tree. The task is to replace the values of each node with the sum of all its subtrees and the node itself. … Read More
Given a binary tree and a number K, the task is to count the number of nodes having the average of the values in their… Read More
Question: Given an arbitrary binary tree, convert it to a binary tree that holds Children Sum Property. You can only increment data values in any… Read More
Given a root of binary tree and two integers startValue and destValue denoting the starting and ending node respectively. The task is to find the… Read More