Java: Height of a Generic Tree from Parent Array

Level : Advanced
Mentor: Shailendra Chauhan
Type : GuidedLab
Points : 10
Duration : 00:50:00

Lab Details

Problem Statement:

We are given a tree of size n as array parent[0..n-1] where every index i in the parent[] represents a node and the value at i represents the immediate parent of that node. For root node value will be -1. Find the height of the generic tree given the parent links.

Self-paced Membership
  • 22+ Courses
  • 750+ Hands-On Labs
  • 200+ Quick Notes
  • 55+ Skill Tests
  • 45+ Interview Q&A
  • 10+ Real-world Projects
  • Career Coaching
  • Email Support
Upto 66% OFF

To get full access to all courses

Still have some questions? Let's discuss.
Accept cookies & close this