Skip to content

Instantly share code, notes, and snippets.

@fabianbaechli
Created April 22, 2025 14:37
Show Gist options
  • Save fabianbaechli/7c4a23cfa4014bdd908d362b68c595f8 to your computer and use it in GitHub Desktop.
Save fabianbaechli/7c4a23cfa4014bdd908d362b68c595f8 to your computer and use it in GitHub Desktop.
struct node* BSTreeSuccAbove(struct node* p, struct node* x) {
struct node* succ = NULL;
while (p != x) {
if (x->key < p->key) {
succ = p;
p = p->lft;
} else if (x->key > p->key) {
p = p->rgt;
}
}
return succ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment