0
Binary search
https://code.sololearn.com/cn1tMXFLR9PX/#java In this program output for searching is always showing an item not found even if it is present over there.
2 odpowiedzi
+ 1
I would place the if( c > 0 ) etc part outside the while loop.
+ 1
Your array may not be sorted and thus not find the values searched for:
example:
5 elements
1, 4, 5, 2, 3
search for 2
first search is done on indice 2 which equals 5 the search value is 2 so 2, 3 are cut out of the remainder of the search.