(1+11)/2=6
(1+5)/2=3
(4+5)/2=4.5 round to 5
I got three.
Type: Posts; User: dx8292
(1+11)/2=6
(1+5)/2=3
(4+5)/2=4.5 round to 5
I got three.
What do mean? I want to see how many comparisons it would take to find 45. The first comparison would be to 45 and the midpoint number (58)
Then the rest of the comparisons would be to each element...
The thing Binary Search I wasn't really sure was when it checks the middle number and if it's not value that was being searched for, does it start searching in reverse order if the first half needs...
Wanted to check if I was doing this correctly.
Binary Search: Find number of comparisons needed
5 11 18 40 45 58 62 75 88 95 100
A. 45 --> 3 needed
B. 96 --> 3 needed