Binary Search

I have to create a search function for a binary tree. The tree is given below:

5
4 8
11 13 4
7 2 1

These are the specific instructions:
1. A function to search for a value in the binary tree given above. The function should return a pointer to that node if the value is found; otherwise the function should return a null pointer. The parameters should be a pointer to the root node of the binary tree and a value to be searched



int main()
{

tptr << " was found in the tree" << endl;

system("PAUSE");
return 0;
}
[/code]

My search function always returns a pointer that is pointing to NULL even though the values are in the tree. How do I correct this?

Thanks
Last edited on
Topic archived. No new replies allowed.