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

# Tag Archives: Trees

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 an array arr[] of size N and Q queries of the form [L, R], the task is to find the number of distinct values… Read More

Given a set of strings S and a string patt the task is to autocomplete the string patt to strings from S that have patt… 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.… Read More

Given a binary tree with N nodes and an integer K, the task is to print nodes of the Kth level of a binary tree… Read More

Given a binary tree, the task is to find the sum of all the nodes whose parent is even. Examples: Input: 1 / \ 3… Read More

Given a graph of N nodes, E edges, a node X and a distance K. The task is to print all the nodes within the… Read More