Skip to main content

Practice · 5 of 5

Debug the binary search

CHALLENGE
Difficulty: beginner+25 XP

This binary search returns wrong (or misses) answers on a sorted array. The algorithm's branch logic is inverted somewhere — trace find({1, 3, 5, 7, 9}, 9) by hand, find the flaw, and fix the branches (structure must stay a binary search).

Back to lesson: Practice: Search & sort reps