## Number of leaf nodes in the subtree of every node of an n-ary tree

Given an N-ary tree, print the number of leaf nodes in the subtree of every node. Examples: Input: 1 / \ 2 3 / |… Read More »

- Number of special nodes in an n-ary tree
- Print all the levels with odd and even number of nodes in it | Set-2
- Determine the count of Leaf nodes in an N-ary tree
- DP on Trees | Set-3 ( Diameter of N-ary Tree )
- Level with maximum number of nodes using DFS in a N-ary tree
- Number of leaf nodes in the subtree of every node of an n-ary tree
- Print levels with odd number of nodes and even number of nodes
- GCD from root to leaf path in an N-ary tree
- Count the nodes whose weight is a perfect square
- Find the node whose sum with X has maximum set bits
- Count the nodes in the given tree whose weight is even parity
- Find the node whose absolute difference with X gives maximum value
- Count the nodes in the given tree whose weight is prime
- Print all leaf nodes of an n-ary tree using DFS
- Count the nodes in the given tree whose weight is a power of two
- Count the nodes of the given tree whose weight has X as a factor

Given an N-ary tree, print the number of leaf nodes in the subtree of every node. Examples: Input: 1 / \ 2 3 / |… Read More »

Given an n-ary tree, print preorder traversal of it. Example : Preorder traversal of below tree is A B K N M J F D… Read More »

Given a K-ary Tree. The task is to write an iterative program to perform the preorder traversal of the given n-ary tree. Examples: Input: 3-Array… Read More »

Given a node x, find the number of children of x(if it exists) in the given n-ary tree. Example : Input : x = 50… Read More »

Given an element x, task is to find the value of its immediate smaller element. Example : Input : x = 30 (for above tree)… Read More »

Given an N-ary tree, find sum of all elements in it. Example : Input : Above tree Output : Sum is 536 Recommended : Please… Read More »

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 »

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 »

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 »

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 »

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 »

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 represented as adjacency list, we need to write a program to count all such nodes in this tree which has more… Read More »

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

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 »