Skip to content

Instantly share code, notes, and snippets.

@fabianbaechli
Created April 22, 2025 14:36
Show Gist options
  • Save fabianbaechli/7112b44411546643b349861058344868 to your computer and use it in GitHub Desktop.
Save fabianbaechli/7112b44411546643b349861058344868 to your computer and use it in GitHub Desktop.
BSTRecCount(struct node* p, int x) {
if (p ≠ NULL) {
if (x < p->val) {
return BSTRecCount(p->lft);
} else if (x > p-val) {
return BSTRecCount(p->rgt);
} else {
return 1 + BSTRecCount(p->lft) + BSTRecCount(p->rgt)
}
} else {
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment