+ 3
Binary Search with Sorting Algorithm HELP
Binary search not working, but sorting does. https://code.sololearn.com/c6jdpzBRg517/?ref=app
3 odpowiedzi
+ 4
The problem is that the value of 'l', which is your 'high' is always 0. In other words, after I input the length of the array, you never change the value of l.
Fix/
Add this at around line 14:
num = sc.nextInt();
a = new int[num];
l = a.length-1; <<<<------(this)
PS: This code was fairly difficult to read, I suggest you work on the readability of your code.
+ 3
Check out my code, I fixed the search for you.
https://code.sololearn.com/cKhIm6TEvFU3/?ref=app
+ 2
works wonders, thanks for helping!