← Quiz: Searching and Sorting in C: all 10 questions
Quiz: Searching and Sorting in C · Question 1 of 10
What must be true before you can use binary search?
What must be true before you can use binary search?
- A.The array must have an even number of elements
- B.The array must be sorted
- C.The array must contain no negative numbers
- D.The array must be stored on the heap
Answer & explanation
Correct answer: The array must be sorted
Binary search decides which half to discard by comparing with the middle; this only works on sorted data.
Can you get the rest right without peeking?
Take the timed Quiz: Searching and Sorting in C quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →