Searching a sorted compact list: use binary search on an array with gaps.
Analyze the searching a sorted compact list: use binary search on an array with gaps..
Examples
Input:"test_input_1"
Output:"output_1"
Input:"test_input_2"
Output:"output_2"
Hints
Consider how binary search can be adapted to work with gaps in the array by treating the gaps as part of the search space.
Recall that binary search relies on the array being sorted. Here, the array is sorted but has gaps—how can you adjust the midpoint calculation to account for these gaps?
Think about how to handle cases where the target value lies within a gap. How would you determine whether the target is present or absent in such scenarios?
Searching a sorted compact list: use binary search on an array with gaps.
Analyze the searching a sorted compact list: use binary search on an array with gaps..