Question 8
Back to Exercise
What happens if you call std::binary_search on an unsorted vector?
- A It sorts the vector first
- B The result is unreliable – the precondition (sorted range) is violated Correct
- C Compile error
- D It throws
Correct Answer: Option B
The library does not check; you get wrong answers silently.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!