posted 3 years ago
I'm digging deep here. Here is my class with the Binary Search method components in it:
The output is this:
Initial Middle Index = [3]
Round 1, sortedNums[middle] < searchInt:
Current firstIndex = [4], with a value of 8,
Current lastIndex = [7], with a value of 14.
New Middle Index = [5], with a value of 9
Remaining Array Half:
8,
Round 2, sortedNums[middle] < searchInt:
Current firstIndex = [6], with a value of 11,
Current lastIndex = [7], with a value of 14.
New Middle Index = [6], with a value of 11
Remaining Array Half:
We found 11 at index [6]
My question is, why didn't 8, print out as 8,9,11,14 instead?