← Quiz: STL Algorithms: all 10 questions
Quiz: STL Algorithms · Question 8 of 10
What does binarysearch require of the range it searches?
What does binary_search require of the range it searches?
- A.Nothing; it works on any range
- B.The range must already be sorted
- C.The range must contain no duplicates
- D.The range must be a set
Answer & explanation
Correct answer: The range must already be sorted
Binary search halves the range by comparing with the middle element, which only works on sorted data.
Can you get the rest right without peeking?
Take the timed Quiz: STL Algorithms quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →