Skip to main content

Checkpoint: Binary search tree contains

Challenge on lesson: Checkpoint: Walk One Path

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.

Difficulty: intermediate

Back to lesson: Checkpoint: Walk One Path