If your method implementation does not animate or animates incorrectly,
check these items:
■
Check the feedback on the output to see ifyour code gives the cor-
rect result.
■
Verify that you coded the base cases correctly.
■
Verify that you coded the general case and its corresponding recur-
sive call correctly.
13.5Binary Search Revisited:A Recursive Solution
In Chapter 8,we presented a binary search algorithm to search a sorted
array for a given value.That algorithm was iterative,using a while loop.
Let’s look at how we can define a recursive solution to this problem.We will
assume that the array is sorted in ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.