Sample code for optimizing binary search based on a look-up table