Data Structure (2130702)

BE | Semester-3   Summer-2016 | 06/09/2016

Q4) (b)

Explain Binary search method.

If we have an array that is sorted, we can use a much more efficient algorithm called a Binary Search.
In binary search each time we divide array into two equal half and compare middle element with search element.
If middle element is equal to search element then we got that element and return that index otherwise if middle element is less than search element we look right part of array and if middle element is greater than search element we look left part of array.