Cognizant interview question

Binary search code