Skip to content

Instantly share code, notes, and snippets.

@fabianbaechli
Last active April 22, 2025 14:34
Show Gist options
  • Save fabianbaechli/ec065317d914359fc6be151459b95e7f to your computer and use it in GitHub Desktop.
Save fabianbaechli/ec065317d914359fc6be151459b95e7f to your computer and use it in GitHub Desktop.
// Iterative
BSTreeSearch(p,v)
while p ≠ NIL AND p->key≠v do
if v<p->key then
p = p->lft
else
p = p->rgt;
return p;
// Recursive
BSTreeSearch(p,v)
if p==NIL OR p->key==v then return p;
if v<p->key then
return BSTreeSearch(p->lft,v)
else
return BSTreeSearch(p->rgt,v);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment