Someone asked about Lazy Binary Searches today. Not knowing what that was, I looked for it, and found this post: What is Lazy Binary Search? Essentially, a Lazy Binary Search is a Binary Search where you compare for inequalities first, and only compare for equality once – at the end.
What’s the point? Under what circumstances is checking if A<B easy to do, but checking if A=B is so hard you want to avoid it if possible?
It’s one less comparison per iteration.
Of course, that’s at the expense of a worse average runtime (you don’t get the opportunity to return early).1 But sometimes all you care about is worst-case runtime (consider hard-real-time applications, or a pipelined hardware implementation).
1. Although the asymptotic complexity doesn’t change.