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.
N-Ary tree can be traversed just like a normal tree. We just have to consider all childs of a given node and recursively call that function on every node.
This article is contributed by Shubham Gupta. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Write a Program to Find the Maximum Depth or Height of a Tree
- Find Minimum Depth of a Binary Tree
- Calculate depth of a full Binary tree from Preorder
- Depth of the deepest odd level node in Binary Tree
- Replace node with depth in a binary tree
- Sum of nodes at maximum depth of a Binary Tree
- Sum of nodes at maximum depth of a Binary Tree | Set 2
- Replace every node with depth in N-ary Generic Tree
- Sum of nodes at maximum depth of a Binary Tree | Iterative Approach
- Minimum valued node having maximum depth in an N-ary Tree
- Find depth of the deepest odd level leaf node
- Complexity of different operations in Binary tree, Binary Search Tree and AVL tree
- Maximum sub-tree sum in a Binary Tree such that the sub-tree is also a BST
- Convert a Generic Tree(N-array Tree) to Binary Tree
- Convert a Binary Tree into its Mirror Tree
- Convert an arbitrary Binary Tree to a tree that holds Children Sum Property
- Check if a binary tree is subtree of another binary tree | Set 1
- Convert a given tree to its Sum Tree
- Binary Tree to Binary Search Tree Conversion
- Check if a given Binary Tree is height balanced like a Red-Black Tree
Improved By : Rajput-Ji