<P> Binary search works on sorted arrays . Binary search begins by comparing the middle element of the array with the target value . If the target value matches the middle element, its position in the array is returned . If the target value is less than or greater than the middle element, the search continues in the lower or upper half of the array, respectively, eliminating the other half from consideration . </P> <P> Given an array A of n elements with values or records A, A,..., A, sorted such that A ≤ A ≤...≤ A, and target value T, the following subroutine uses binary search to find the index of T in A . </P> <Ol> <Li> Set L to 0 and R to n − 1 . </Li> <Li> If L> R, the search terminates as unsuccessful . </Li> <Li> Set m (the position of the middle element) to the floor (the largest previous integer) of (L + R) / 2 . </Li> <Li> If A <T, set L to m + 1 and go to step 2 . </Li> <Li> If A> T, set R to m − 1 and go to step 2 . </Li> <Li> Now A = T, the search is done; return m . </Li> </Ol> <Li> Set L to 0 and R to n − 1 . </Li>

Write a binary search program in data structure