🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Sorting Basics: questions with answers

13 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. What does this print? (code)
  2. Q2. Which simple sort is fastest on an array that is already almost sorted?
  3. Q3. Which of these sorts is NOT stable in its usual form?
  4. Q4. What is the best-case time of bubble sort with the "stop if no swap" check?
  5. Q5. You must sort an array where every write to memory is very costly. Which simple sort writes the least?
  6. Q6. How much extra memory do bubble, selection and insertion sort need?
  7. Q7. After the FIRST pass of bubble sort on [5, 1, 4, 2, 8], what is the array?
  8. Q8. An array has 100,000 items. Why is insertion sort a poor choice here?
  9. Q9. What does this print? (code)
  10. Q10. After the FIRST pass of selection sort on [29, 10, 14, 37, 13], what is the array?
  11. Q11. At most how many swaps does selection sort make on n items?
  12. Q12. Why is the largest value always at the end after the first pass of bubble sort?
  13. Q13. For which input does insertion sort do the most work?