Computer Science, asked by Alwaysstill7575, 1 year ago

Binary search is applicable in data that is stored in what way?

Answers

Answered by Rajdeep11111
0
Heyy there! I'm Rajdeep......... you can follow me and ask me about your doubts in your Computer..and any other subject!

Binary search is applicable to data that is stored in a SORTED way l, either in ascending or in descending.
This is because binary search first divides the array into two, and if the element to be searched is greater than the middle position of the array, then the element is searched on the upper half of the array and if the element to be searched is smaller than the value of middle, then the element is searched in the lower half of the array.

So if the array is not sorted, the element which is greater than the element in the middle, may be present in the lower half and the search will continue in the upper half....and the final result would be "RESULT NOT FOUND" although the element was present in the array!
Similar questions