Introduction
Binary search is one of those algorithms that's easy to understand at a glance, but often hard to work out the implementation details. For example, should it be $$$\text{lo}=0$$$ or $$$\text{lo}=1$$$? Should I set $$$\text{lo}$$$ to $$$\text{mid}$$$ or $$$\text{mid}+1$$$? Is the answer that I should return $$$\text{lo}$$$ or $$$\text{hi}$$$? The questions are endless.




