In the binary tree tutorial, i am having a little trouble understanding one part of the code.
why is it neccessary to use node(a struct) as the return type? (rest of the code is in tutorial, too long to postCode:node *btree::search(int key, node *leaf) { if(leaf!=NULL) { if(key==leaf->key_value) return leaf; if(key<leaf->key_value) return search(key, leaf->left); else return search(key, leaf->right); } else return NULL; })
instead of using something like this, and changing the rest of the code to match it.
just curious, all i need is to be pointed in the right direction, thanks in advanceCode:int *btree::search(int key, node *leaf) { if(leaf!=NULL) { if(key==leaf->key_value) return leaf; if(key<leaf->key_value) return search(key, leaf->left); else return search(key, leaf->right); } else return NULL; }![]()



LinkBack URL
About LinkBacks
)


