Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

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.

Figure 1 Snippet for the algorithm (For loop)

Working of Binary search


The two methods to implement binary search algorithm:

 Iterative method
 Recursive method

This recursive method uses the divide and conquer approach

Elements of the array:

K = 56.

So, in the established array –

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.

4 = mid of the array.


References

Javatpoint. (2021). Binary search - javatpoint. www.javatpoint.com. Retrieved December 18,


2021, from https://www.javatpoint.com/binary-search

You might also like