All lessons

7. Sorting

Sorting complexity cheat sheet

0 of 5 activities0%

Reading 1

What to remember

Open

Comparison sorts need Ω(n log n) in the worst case in general.

Stable: merge sort (typical), insertion, bubble (careful). Unstable: quick, heap, selection.

Prefer library sort (introsort) in production; know the classics for interviews.

Check 2

Lower bound

Open

Comparison-based sorting lower bound is

Fill in 3

Stable meaning

Open

A sort that preserves order of equal keys is called

Try it 4

std::sort

Open

Use the library.

main.cpp
Loading editor…
Output will appear here.

Assignment 5

Is sorted?

Open

Read n and n ints. Print yes if nondecreasing, else no.

main.cpp
Loading editor…