Skip to main content

Checkpoint: Binary search tree contains

Challenge on lesson: Checkpoint: Walk One Path

CHALLENGE
Difficulty: intermediate+25 XP

Implement bool bst_contains(const TreeNode* n, int v) on the given TreeNode {int value; TreeNode* left; TreeNode* right;} (left < node < right). Walk ONE path using the ordering โ€” the recursive left-or-right branch, not both. Then implement TreeNode* bst_insert(TreeNode* n, int v) (ignore duplicates) so the second test can build a tree. Everything else is provided.

Back to lesson: Checkpoint: Walk One Path