What is binary search?

 Ans-:

BINARY SEARCH:

The Binary search technique is a search technique which is based on Divide & Conquer strategy. The entered array must be sorted for the searching, then we calculate the location of mid element by using formula mid= (Beg + End)/2, here Beg and End represent the initial and last position of array. In this technique we compare the Key element to mid element. So there May be three cases:-

·     If array[mid] = = Key (Element found and Location is Mid)

·     If array[mid] > Key, then set End = mid-1. (continue the process)

·     If array [mid] < Key, then set Beg=Mid+1. (Continue the process)

Post a Comment

Thankyou

Previous Post Next Post