The Binary search algorithm assumes that the items in the array are _____ and…
2023
The Binary search algorithm assumes that the items in the array are _____ and it either finds the item or eliminates half of the array with one comparison.
- A.
Unsorted
- B.
Sorted
- C.
Checked
- D.
Selected
Attempted by 700 students.
Show answer & explanation
Correct answer: B
Binary search is an efficient algorithm for finding an item in a sorted array. It works by repeatedly dividing the search interval in half. If the value of the search key is less than the item in the middle of the interval, the search continues in the lower half. Otherwise, it continues in the upper half. This process continues until the value is found or the interval is empty.
The key requirement for binary search is that the array must be sorted. Without sorting, the algorithm cannot reliably eliminate half of the remaining elements based on a single comparison. This is because the relative order of elements is essential for determining which half of the array to search next.