hello there!

i'd kindly like to ask your comments about this function.

The assignment is to write a function which searches for a given key in a binary tree and returns 1 if the key is found, 0 if not. The function should stop searching if the key is met.

I wrote this:

I used the several IF to have clearer what happens (i still have some problems with recursion).. According to you, is this function formally a good solution to the given problem?Code:int searchTree (NodePtr headPtr,int key) { if (headPtr==NULL) { return 0; } else { if (headPtr->value==key) { return 1; } else if (search (headPtr->leftPtr,key)) { return 1; } else { if (search (headPtr->rightPtr,key)) { return 1; } else { return 0; } } } }

many thanks (once again! )