Data Structures and Algorithms20795 marksIntroduction to Searching, Search Algorithms
Write a program to implement binary search.
Write a program to implement binary search. [5]
Binary search works on a sorted array by repeatedly dividing the search interval in half. It compares the target key with the middle element and narrows the search to the left or right sub-list accordingly. --- --- --- --- Step l r m a[m] Action ----------------------------- 1 0 6 3 40 key == a[m...