Snapsheet interview question

Write the binary search algorithm.