Write a C program to find the mininum value in a binary search tree.

October 28, 2007 · Filed Under Placement Questions, Tree 



Don't want to miss a single bit? Subscribe By Email for Daily Jobs

Enter your email address :

All the latest from JobsAdda on Jobsadda.com delivered to your mailbox everyday.

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


Get Latest JobsAdda.com Jobs, news & updates  via Email