I am trying to find if a given key is present or not in a binary tree. I want to return the pointer to node if the key is present. I am unable to decide how to carry forward the key once found.
Node* findNode(Node*root,int ele){
if(!root)
return NULL;
if(root->data==ele)
return root;
findNode(root->left,ele);
findNode(root->right,ele);
}
Aucun commentaire:
Enregistrer un commentaire