in reply to Re^7: Binary search algorithm.
in thread Binary search algorithm.

So... you are for optimization over clarity? As Donald Knuth has said:

Yes. T'is a shame that so few of the many that quote him really understand what they quote.

If clarity is your only goal, then why are you using a binary search? A linear search is easier to program correctly and far clearer to read.

The very fact that a binary search is being considered means that someone has acknowledged that performance is sometimes important enough, to trade the performance that comes from its complexity, against the simple clarity of grep.

And small efficiencies at the core of frequently used, expensive processes -- like searching -- are the exact 3% that should be optimised. If you'd read Knuth rather than just quoting him, you'd know that,


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.