Given an array of pairs Edges[][], representing edges connecting vertices in a Tree consisting of N nodes, the task is to find the minimum time… Read More

# Tag Archives: n-ary-tree

Given an N-ary tree consisting of N nodes, the task is to find the node having the largest value in the given N-ary Tree. Examples:… Read More

Given an N-ary tree consisting of N nodes having values 0 to (N – 1), the task is to find the total number of subtrees… Read More

Given an N-Ary tree, the task is to print all root to leaf paths of the given N-ary Tree. Examples: Input: … Read More

Given an array weights[] consisting of N positive integer, where weights[i] denotes the weight of ith node, the task is to construct an N-ary tree… Read More

Given an N-ary tree and an element X, the task is to print the siblings of the node with value X. Two nodes are considered… Read More

Given an N-array tree of N nodes, rooted at 1, with edges in the form {u, v}, and an array values[] consisting of N integers.… Read More

Prerequisite: Generic Trees(N-array Trees) In this article, we will discuss the conversion of the Generic Tree to a Binary Tree. Following are the rules to… Read More

Given a N-ary Tree consisting of nodes valued in the range [0, N – 1] and an array arr[] where each node i is associated… Read More

Given an N-ary Tree consisting of nodes valued [1, N] and an array value[], where each node i is associated with value[i], the task is… Read More

Given an N-ary tree, the task is to find the maximum width of the given tree. The maximum width of a tree is the maximum… Read More

Given an N-ary tree and an integer K, the task is to print the Kth ancestors of all the nodes of the tree in level… Read More

Given an N-ary Tree rooted at 1, the task is to find the difference between the sum of nodes at the odd level and the… Read More

Given a N-ary tree with N vertices rooted at 1 and a set of vertices as V[], the task is to print any such vertex… Read More

Given an array arr[] representing a Generic(N-ary) tree. The task is to replace the node data with the depth(level) of the node. Assume level of… Read More