Skip to content

Tag Archives: Trees

Given a binary tree, the task is to compress all the nodes on the same vertical line into a single node such that if the… Read More
Given a Binary Tree consisting of N nodes, the task is to first compress the tree diagonally to get a list of integers and then,… Read More
Given an N-ary Tree consisting of N nodes valued from 1 to N, an array arr[] consisting of N positive integers, where arr[i] is the… Read More
Given a Binary Tree, the task is for each level is to print the total number of nodes from all lower levels which are less… Read More
Given a Binary Tree, the task is to find the length of the longest straight path of the given binary tree. Straight Path is defined… Read More
Given a string S of Size N. Initially, the value of count is 0. The task is to find the value of count after N… Read More
Prerequisite: graphics.h, How to include graphics.h?  In C/C++ there is graphics.h header file which is used to create the object like line, circle, etc. Given an… Read More
Given a Tree with N nodes values from 1 to N and N – 1 edges. The task is to find the maximum matching in… Read More
Given a Tree, the task is to find the farthest node from each node to another node in the given tree. Examples   Input:  Output: 2… Read More
Given a rooted tree having N vertices, an array values[ ], which represents the value assigned to each node, and a vertex V, the task… Read More
Given an N-ary Tree rooted at 1, and an array val[] consisting of weights assigned to every node, and a matrix Q[][], consisting of queries… Read More
Given a tree with the weights of all the nodes, the task is to count the number of nodes whose weight is a Fibonacci number.Examples:  … Read More