Compare the main sorting algorithms.

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).

Think of your own answer first

Say it out loud, or type it below. What you type never leaves this device.

Follow-up questions

These are likely next questions from an interviewer. Think of your answer first, then press the button.

  1. 1 / 3

    Why does a stable sort matter?

Sources checked

This is a textbook level concept, so no outside source is listed.