Wednesday, August 15, 2007

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

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.

4 comments:

Joy said...

Thanks for the post

You can find some good Techical Interview Question Answers on in the below link

Technical Interview Question Answers

Thanks
Joya

Job Interview Question Answers said...

Nice post . . Very Useful information

Dhung.com provid interview question and answer for all company.

sandeep kumar said...

Thanks for the info.
Regards
Educational site

Anonymous said...

If you would like to increase your experience just keep visiting this web site and be updated with the most up-to-date information posted here.



my blog post selling a wrecked car