## Height of a generic tree from parent array

We are given a tree of size n as array parent[0..n-1] where every index i in parent[] represents a node and the value at i… Read More »

## Diameter of n-ary tree using BFS

N-ary tree refers to the rooted tree in which each node having atmost k child nodes. The diameter of n-ary tree is the longest path… Read More »

## Number of nodes greater than a given value in n-ary tree

Given a n-ary tree and a number x, find and return the number of nodes which are greater than x. Example: In the given tree,… Read More »

## Next Larger element in n-ary tree

Given a generic tree and a integer x. Find and return the node with next larger element in the tree i.e. find a node just… Read More »

## Second Largest element in n-ary tree

Given an N-ary tree, find and return the node with second largest value in the given tree. Return NULL if no node with required value… Read More »

## Node having maximum sum of immediate children and itself in n-ary tree

Given an N-Ary tree, find and return the node for which sum of data of all children and the node itself is maximum. In the… Read More »

## Given a n-ary tree, count number of nodes which have more number of children than parents

Given a N-ary tree represented as adjacency list, we need to write a program to count all such nodes in this tree which has more… Read More »

## General Tree (Each node can have arbitrary number of children) Level Order Traversal

Given a generic tree, perform a Level order traversal and print all of its nodes Examples: Input : 10 / / \ \ 2 34… Read More »

## DFS for a n-ary tree (acyclic graph) represented as adjacency list

A tree consisting of n nodes is given, we need to print its DFS. Examples : Input : Edges of graph 1 2 1 3… Read More »

## Height of n-ary tree if parent array is given

Given a parent array P, where P[i] indicates the parent of ith node in the tree(assume parent of root node id indicated with -1). Find… Read More »

## Construct the full k-ary tree from its preorder traversal

Given an array which contains the preorder traversal of full k-ary tree, construct the full k-ary tree and print its postorder traversal. A full k-ary… Read More »

## Check mirror in n-ary tree

Given two n-ary trees, the task is to check if they are mirror of each other or not. Print “Yes” if they are mirror of… Read More »

## Creating a tree with Left-Child Right-Sibling Representation

Left-Child Right-Sibling Representation is a different representation of an n-ary tree where instead of holding a reference to each and every child node, a node… Read More »

## Left-Child Right-Sibling Representation of Tree

An n-ary tree in computer science is a collection of nodes normally represented hierarchically in the following fashion. The tree starts at the root node.… Read More »

## Longest path in an undirected tree

Given an undirected tree, we need to find the longest path of this tree where a path is defined as a sequence of nodes. Example:… Read More »