Binary Search Doubt

Revision en1, by Learning_CP, 2017-06-02 09:24:34

Hello All, I have doubt in Binary Search Algorithm. Like in yesterday's contest 417(Div. 2), there was a problem C Sagheer and Nubian Market . I saw in the editorial and many solutions of the top coders as well. Some people have started binary Search with while(low <= high) this condition, some have started with while(high — low > 1) this condition and some have did it with while(low < high) . I have a doubt, how do we decide that which loop condition we have to apply and how we get the answer ? Can somebody explain this with yesterday's C problem ! Link to the problem:- Link Thanks !

Tags binary seach

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Learning_CP 2017-06-02 09:24:34 726 Initial revision (published)