Home » Data Structure & Algorithms » minimum value node in a Binary Search Tree

minimum value node in a Binary Search Tree

 

Question :

WAP to find the node with minimum value in a binary search Tree.

 

Algorithm :

The problem is solved in recursive way.

Hint : Inorder(left->root->right)  traversal of BST gives a ascending sorted array,so the minimum value node should lie in left most node of left sub-tree.In the figure shown above “Node 1” is the minimum value node.

Step 1 : If the node is null ,then return null.

Step 2 : Traverse the tree from root to left sub tree till we reach null.

Step 3 : The node found by step 2 is the node with minimum value(left most leaf).

Program :

 
 


Leave a comment

Your email address will not be published. Required fields are marked *

twenty + fourteen =