A great lathe operator commands several times the wage of an average lathe operator, but a great writer of software code is worth 10,000 times the price of an average software writer. Bill Gates

Inorder predecessor and successor for a given key in BST

Language Java | Level Intermediate | Category Data structure | September 8, 2015 8:00 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.