Code By Martin

Binary Search

| Comments

Mike Taylor noted in a blog post that in the book Programming Pearls it is mentioned that no more than 10% of developers can correctly implement a binary search. Appalling!

Let’s see if I am in that 10% or not…

As I’ve found myself using Ruby more and more lately, I thought I’d try to implement the binary search using that language.

Here’s my stab:

The script includes code to run the binary search through the test cases for the exercise created by Steve Witham. And once the file reading worked - all tests actually passed (or the code incorrectly shows them as passed… ;).

Good training this!

/M

Comments