In which scenario does binary search fail to work?
Practice Questions
Q1
In which scenario does binary search fail to work?
When the array is sorted
When the array is unsorted
When the array contains duplicates
When the array is empty
Questions & Step-by-Step Solutions
In which scenario does binary search fail to work?
Step 1: Understand what binary search is. It is a method to find an item in a sorted array by repeatedly dividing the search interval in half.
Step 2: Know that binary search only works if the array is sorted in a specific order (either ascending or descending).
Step 3: Realize that if the array is not sorted, the binary search will not be able to correctly find the item because it relies on the order of elements.
Step 4: Conclude that binary search fails when applied to unsorted arrays.