Java: Find next right node of a given key

Level : Intermediate
Mentor: Shailendra Chauhan
Type : GuidedLab
Points : 10
Duration : 00:30:00

Lab Details

Problem Statement:

Given a Binary tree and a key in the binary tree, find the node right to the given key. If there is

no node on right side, then return NULL. Expected time complexity is O(n) where n is the number

of nodes in the given binary tree.

Example

Consider the following Binary Tree. Output for 2 is 6, output for 4 is 5. Output for 10, 6 and 5 is

NULL.

 10
 / \
 2  6
/ \  \
8   4  5
Self-paced Membership
  • 24+ Video Courses
  • 825+ Hands-On Labs
  • 400+ Quick Notes
  • 125+ Skill Tests
  • 10+ Interview Q&A Courses
  • 10+ Real-world Projects
  • Career Coaching Sessions
  • Email Support
Upto 60% OFF
Know More
Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this