Good code is its own best documentation. As you are about to add a comment, ask yourself, How can I improve the code so that this comment isn't needed? Improve the code and then document it to make it even clearer. Steve McConnell

Inorder Successor in Binary Search Tree

Language Java | Level Intermediate | Category Data structure | September 6, 2015 7:41 am

Data structure Description

Write a program to find Predecessor and Successor of the given node in the Binary Search Tree.

If the node has two children, its predecessor is the maximum value in its left subtree and its successor the minimum value in its right subtree. If it does not have a left child, a node's predecessor is its first left ancestor.



All Binary Tree Values: 4 8 10 12 14 20 22  
Predecessor of 14 is 12
Successor of 14 is 20



No comments available!

Please login to add comments.