searching value in binary_tree

hello,
i have problem with these functions that return the id of a node of a binary tree.




int binary_tree::get_id_from_key(int key)
{
node *aux=search(root,key);
return aux->id_node;
}


node* binary_tree::search(node *&ptr,const int n)
{

if(ptr!=NULL)
{
if(ptr->key==n)
return ptr;
else if(n>ptr->key)
return search(ptr->right,n);
else return search(ptr->left,n);
}
else return 0;
}


the question is: is it right to return 0 if i don' t find the node containing value n?
in this case what should i return in the function get_id_from_key?

thanks in advance guys
Topic archived. No new replies allowed.