Sie sind auf Seite 1von 1

Non Recursive Search function for binary search tree

struct bst * find(int elt, struct bst *t)


{
if (t == NULL)
{
printf("\nTree is empty");
return NULL;
}
while(t != NULL)
{
if(elt == t->data)
return t;
else if(elt < t->data)
t = t->lc;
else
t = t->rc;
}
return NULL;
}