113. Searching and Sorting-I

Question.1

A developer searches for value 8 in a sensor lookup table using binary search:

int arr[] = {20, 5, 15, 8, 30};
int idx = binary_search(arr, 5, 15);

The function returns -1 (not found), even though 8 is at index 3. What went wrong?

Need Help? Refer to the Quick Guide below

Select Answer