Relative Content

Tag Archive for algorithmbinary-search

low < high vs low 1 in Binary search

I am confused about the terminating condition of the loop in binary search. I have also seen some solutions where high - low > 1 is used. I need some explanations to understand when to use low < high, low <= high and high - low > 1.

low < high vs low 1 in Binary search

I am confused about the terminating condition of the loop in binary search. I have also seen some solutions where high - low > 1 is used. I need some explanations to understand when to use low < high, low <= high and high - low > 1.