Level 1: Bronze
A memorized definition. Not wrong, but it stops there.
Quick sort and merge sort are fast.
3 stars If you are short on time, start with this one.
In one or two sentences
Quick sort is O(n log n) on average and O(n^2) in the worst case. Merge sort is always O(n log n) but needs extra space. Selection, insertion and bubble sort are O(n^2).
Say it out loud, or type it below. What you type never leaves this device.
A memorized definition. Not wrong, but it stops there.
Quick sort and merge sort are fast.
Correct, but too broad or missing context.
Bubble, selection and insertion sort are O(n^2). Merge sort is always O(n log n). Quick sort is O(n log n) on average and O(n^2) in the worst case.
Reaches principle, use and trade-off, with words that invite the next question.
Comparison sorts cannot beat O(n log n) in general. Quick sort degrades with a bad pivot, but it works in place and fits the cache, so it is fast in practice. Merge sort is stable and always O(n log n), at the cost of O(n) auxiliary space. A stable sort keeps the original order of equal keys. Insertion sort is quick on small or nearly sorted input, so real libraries mix it in for small ranges. For integers in a small key range, counting sort avoids comparisons and runs in O(n + k).
These are likely next questions from an interviewer. Think of your answer first, then press the button.
1 / 3
Why does a stable sort matter?
When you sort by several keys in turn, the order from the earlier key must survive among equal keys of the later one.
2 / 3
How do you avoid quick sort's worst case?
Pick the pivot at random, or as the median of the first, middle and last. That stops sorted input from leaning to one side.
3 / 3
Can you sort without comparisons?
For integers in a small range, counting sort or radix sort gets close to O(n). The cost is a constraint on the key form.
This is a textbook level concept, so no outside source is listed.