Given a perfect binary tree consisting of N nodes, the task is to check if the number formed by the nodes in any level of… Read More

# Category Archives: Tree

Given a binary tree and an integer K, the task is to print all the nodes having children with the same remainder when divided by… Read More

Given a binary tree and an integer K. The task is to count the number of nodes having children that give the same remainder when… Read More

Given 1 to N vertices of a non-cyclic undirected graph with (N-1) edges. The task is to assign values to these edges so that the… Read More

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