Top Sorting Algorithm Interview Questions and Answers
This is a quick-reference list of the sorting questions that appear most often in technical interviews, each with a concise, correct answer. Use them to self-test, then practice explaining each one aloud while watching the algorithm in the visualizer.
Complexity questions
Q: What is the time complexity of Quick Sort? O(n log n) average, O(n²) worst, O(log n) space.
Q: Why is O(n log n) the best a comparison sort can do? The decision-tree lower bound requires log2(n!) comparisons.
Q: Which sorts guarantee O(n log n)? Merge Sort and Heap Sort, on every input.
Choice and property questions
Q: Which sort is best for nearly-sorted data? Insertion Sort or Tim Sort.
Q: Which sorts are stable? Merge, Insertion, Bubble, Counting, Radix, Tim.
Q: Which uses the least memory? Heap Sort, O(1).
Q: When does Counting Sort beat Quick Sort? Small integer range relative to n.
Conceptual questions
Q: Difference between comparison and non-comparison sorts? See our explainer.
Q: What is a hybrid sort? Tim Sort and Introsort combine algorithms for the best of each.
Q: Why is Quick Sort faster than Merge Sort? Cache locality and in-place operation.
Frequently asked questions
What are the most common sorting interview questions? +
How should I prepare for sorting interview questions? +
See it in motion
Watch this algorithm and 9 others run step by step in our free interactive visualizer.
▶ Launch Visualiser