Question: Binary Search is performed on a sorted set of elements, it compares the number to be found with the middle element, if it is not

Binary Search is performed on a sorted set of elements, it compares the number to be found with the middle element, if it is not the same, then it checks which (left or right) subarray will contain the element, if mid is less than element, then it would be found in right subarray, similarly for left subarray. Time Complexity: O( log n ) Space Complexity: O( 1 ) Binary Search considerably reduces the search time if the data is sorted. Binary search is not used when the array changes often, or if the elements are unsorted.

Step by Step Solution

3.41 Rating (154 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Respected SirMadam Here I am using python for searching an eleme... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!