Logic of Binary search