I have a problem I have an array that's being used in a binary search, I am looking for a number in the array and every time the search comes false I'm suppose to make a new array out of that search either looking in the bottom half or the upper half using a while loop.
This is how far I've gotten with how my professor wanted it but every binary search I've looked at is used differently than the way I'm trying to do it not sure if its possible to do this way or if I messed up something.
Just looking for the next step so I can try to proceed and finish
// Linear Search
var set = [45, 12, 87, 102, 97, 24, 11, 1, 23, 59, 87];
var number = 87;
for(var i = 0; i < set.length; i++){
var current = set[i];
if (current == number) {
console.log(i);
break;
}
}
// Binary search
var set = [1, 2, 6, 9, 15, 35, 44, 55, 67, 78, 85];
var number = 78;
for(var i = set.length / 2; i< set.length;){
var current = set[i];
var found = false;
while (!found) {
}
}