# Tag Archives: n-ary-tree

## Print siblings of a given Node in N-ary Tree

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 »

## Largest subtree sum for each vertex of given N-ary Tree

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 »

## Convert a Generic Tree(N-array Tree) to Binary Tree

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 »

## Maximum value at each level in an N-ary Tree

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 »

## Maximum level sum in N-ary Tree

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 »

## Maximum width of an N-ary tree

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 »

## Kth ancestor of all nodes in an N-ary tree using DFS

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 »

## Difference between sums of odd level and even level nodes in an N-ary Tree

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 »

## Find node U containing all nodes from a set V at atmost distance 1 from the path from root to U

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 »

## Replace every node with depth in N-ary Generic Tree

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 »

## Remove all leaf nodes from a Generic Tree or N-ary Tree

Given a Generic tree, the task is to delete the leaf nodes from the tree.  Examples: Input: 5 / / \ \ 1 2 3… Read More »

## Find the node at the centre of an N-ary tree

Prerequisites:  Diameter of a N-ary tree Path between two nodes in a graph Given a N-ary tree with N nodes numbered from 0 to N-1… Read More »

## Count of subtrees from an N-ary tree consisting of single colored nodes

Given a N-ary tree consisting of N nodes and a matrix edges[][] consisting of N – 1 edges of the form (X, Y) denoting the… Read More »

## Isomorphism in N-ary Trees

Given two N-ary trees having M nodes each. Also, given their edges and their roots respectively. The task is to check if they are isomorphic… Read More »

## Maximum sum possible for every node by including it in a segment of N-Ary Tree

Given an N-Ary tree containing N nodes and an array weight [ ] that denotes the weight of the nodes which can be positive or… Read More »