← All topics
Quiz: Searching and Sorting in C: questions with answers
10 questions, each with the answer and a short explanation.
Take the timed quiz + get a certificate →- Q1. What must be true before you can use binary search?
- Q2. At most how many comparisons does binary search need for 1,000 sorted elements?
- Q3. What does this print? (code)
- Q4. Which sort makes the same number of comparisons whether the input is sorted or not?
- Q5. What is the best-case time of insertion sort, and when does it happen?
- Q6. Why write mid = low + (high - low) / 2 instead of (low + high) / 2?
- Q7. What does this print? (code)
- Q8. What does "stable sort" mean?
- Q9. What is the main advantage of selection sort?
- Q10. In insertion sort, why must the condition be j = 0 && a[j] key in that order?