## LCA for n-ary Tree | Constant Query O(1)

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 »

## Diameter of an N-ary tree

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 »

## Depth of an N-Ary tree

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 »

## LCA for general or n-ary trees (Sparse Matrix DP approach )

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 »

## Number of ways to traverse an N-ary tree

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 »

## Locking and Unlocking of Resources arranged in the form of n-ary Tree

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 »

## Mirror of n-ary Tree

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 »

## Serialize and Deserialize an N-ary Tree

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 »