Algorithms and Data Structures · Junior · Question 31 of 75

What does binary search require from the data?

Explanation

Binary search compares the target with the middle element and discards the half where it cannot be. That decision only makes sense if the array is sorted. Duplicates are fine.

Further reading

Problem with a question

Algorithms and Data Structures · Junior · question 31

Test yourself

Take the Algorithms and Data Structures · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz