Write a C program to find the mininum value in a binary search tree.
October 28, 2007 · Filed Under C Interview Questions, Placement Questions
![]() Don't want to miss a single bit? Subscribe By Email for Daily Jobs |
Here is some sample C code. The idea is to keep on moving till you hit the left most node in the tree
int minValue(struct node* node)
{
struct node* current = node;
while (current->left != NULL)
{
current = current->left;
}
return(current->data);
}
On similar lines, to find the maximum value, keep on moving till you hit the right most node of the tree.
Related Articles
- Write a C program to find the mininum value in a binary search tree.
- Write C code to check if a given binary tree is a binary search tree or not?
- Write a C program to remove duplicates from a sorted linked list
- Write a C program to insert nodes into a linked list in a sorted fashion
- Write C code to return a pointer to the nth node of an inorder traversal of a BST.


