Cognizant interview question

Explain binary search and write it's code