## Inorder traversal of an N-ary Tree

Given an N-ary tree containing, the task is to print the inorder traversal of the tree. Examples: Input: N = 3 Output: 5 6 2… Read More »

## Iterative Postorder Traversal of N-ary Tree

Given an N-ary tree, the task is to find the post-order traversal of the given tree iteratively. Examples: Input: 1 / | \ 3 2… Read More »

## Left-Right traversal of all the levels of N-ary tree

Given a Complete Binary Tree rooted at node 1, the task is to print the elements in the following defined order. First, print all elements… Read More »

## Find distance of nodes from root in a tree for multiple queries

Given a tree with N vertices numbered from 0 to N – 1 and Q queries containing nodes in the tree, the task is to… Read More »

## Find parent of each node in a tree for multiple queries

Given a tree with N vertices numbered from 0 to N – 1 and Q query containing nodes in the tree, the task is to… Read More »

## Insertion in n-ary tree in given order and Level order traversal

Given a set of parent nodes where the index of the array is the child of each Node value, the task is to insert the… Read More »

## Check if the given n-ary tree is a binary tree

Given an n-ary tree, the task is to check whether the given tree is binary or not. Examples: Input: A / \ B C /… Read More »

## Generic Trees(N-array Trees)

The Generic trees are the n-ary trees which have the following properties: Many children at every node. The number of nodes for each node is… Read More »

## Count the nodes of the given tree whose weight has X as a factor

Given a tree, and the weights of all the nodes, the task is to count the nodes whose weights are divisible by x. Examples: Input:… Read More »

## Count the nodes in the given tree whose weight is even parity

Given a tree and the weights of all the nodes, the task is to count the number of nodes whose weights are even parity i.e.… Read More »

## Print all leaf nodes of an n-ary tree using DFS

Given an array edge[] where (edge[i], edge[i]) defines an edge in the n-ary tree, the task is to print all the leaf nodes of the… Read More »

## Count the nodes in the given tree whose weight is a power of two

Given a tree, and the weights of all the nodes, the task is to count the number of nodes whose weight is a power of… Read More »

## Count the nodes in the given tree whose weight is prime

Given a tree, and the weights of all the nodes, the task is to count the number of nodes whose weight is prime. Examples: Input:… Read More »

## Count the nodes whose weight is a perfect square

Given a tree, and the weights of all the nodes, the task is to count the number of nodes whose weight is a perfect Square.… Read More »

## Find the node whose sum with X has maximum set bits

Given a tree, and the weights of all the nodes and an integer x, the task is to find a node i such that weight[i]… Read More »