## 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 »

- 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
- Find the node whose sum with X has maximum set bits
- Count the nodes whose weight is a perfect square
- Find the node whose absolute difference with X gives maximum value
- Count the nodes in the given tree whose weight is prime

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 »

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 »

We have seen various methods with different Time Complexities to calculate LCA in n-ary tree:- Method 1 : Naive Method ( by calculating root to… Read More »

The diameter of an N-ary tree is the longest path present between any two nodes of the tree. These two nodes must be two leaf… Read More »

Given an N-Ary tree, find depth of the tree. An N-Ary tree is a tree in which nodes can have at most N children. Examples:… Read More »

In previous posts, we have discussed how to calculate the Lowest Common Ancestor (LCA) for a binary tree and a binary search tree (this, this… Read More »

Given an n-ary tree, count number of ways to traverse an n-ary (or a Directed Acyclic Graph) tree starting from the root vertex. Suppose we… Read More »

Given an n-ary tree of resources arranged hierarchically such that height of tree is O(Log N) where N is total number of nodes (or resources).… Read More »

Given a Tree where every node contains variable number of children, convert the tree to its mirror. Below diagram shows an example. We strongly recommend… Read More »

Given an N-ary tree where every node has at-most N children. How to serialize and deserialze it? Serialization is to store tree in a file… Read More »