Professional Documents
Culture Documents
Binary Search Algorithm
Binary Search Algorithm
The divide and conquer strategy are used in binary search, in which the list is divided into two
halves and the item is compared to the list's middle element. The position of the middle element
is returned if a match is discovered. Otherwise, we look in either of the halves, depending on the
match's outcome.
Iterative method
Recursive method
K = 56.
We would also be using the formula of mid = (beg + end)/2 to calculate the mid of the array.
beg = 0
end = 8
mid = (0 + 8)/2 = 4.