Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 2
    Also, if the 1 book you're looking for happens to be among the first, the linear search will outperform. To get a better sense of the time, you would have to search for thousands of books, and average the times. Commented Jun 3, 2021 at 19:05
  • 1
    FYI, This binary search code has the classic binary search overflow bug Commented Jun 3, 2021 at 19:09
  • Using a debugger to step through your code would have shown you immediately what’s going on. Commented Jun 3, 2021 at 19:39