Understanding a Binary Search.
What is a binary search, and how does it work?© SolutionLibrary Inc. solutionlibary.com 9836dcf9d7 https://solutionlibrary.com/computer-science/software-development/understanding-a-binary-search-2gq
...orm a test to see if the number we are looking for is greater than the number we just referenced in the sorted list, and 12 > 6. Since we know that the number we have just looked at is less than the value we are looking for, we can automatically discard half of the array!
After pruning the sorted list, we only need to look at the following:
8, 9, 10, 12, 15
We're down to half of the elements already! We repeat what we did above, and find the middle element in the sorted list. (1+5)/2 = 3, and the third element is 10. We check the result of 12 > 10, find that it is true, and discard the elements we ...