+ 2

The 1st and 2nd number doesnt appear to be found. Pls help me. (Binary Search)

https://code.sololearn.com/cv6G4016E80y/?ref=app

23rd Jun 2017, 11:40 AM
Joe McMillan
Joe McMillan - avatar
2 Respuestas
+ 8
The reason why it isn't working is primarily because binary search algorithm requires your set of data to be sorted. The data in the array you provided is unsorted. Your code works fine after I rearranged the array values.
23rd Jun 2017, 11:57 AM
Hatsy Rei
Hatsy Rei - avatar
+ 2
Thanks, I didn't know that it must be sorted first. Anyways, great help!
23rd Jun 2017, 2:43 PM
Joe McMillan
Joe McMillan - avatar