Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 01 · DSA · The toolbox · about 25 min to read

Play it as a journeyTutor comes with a plan

Rolling dice on purpose: randomized algorithms

Sorting and Searching
Sorting and Searching · Open board

The board that splits a pile around one pivot. Here the pivot is chosen by chance, and every structure in this lesson uses chance the same way: to make the bad cases rare.

Lesson 9 of 96 in DSA

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 2010: a fair ballot that was not fair
  • A fair shuffle: every order equally likely
  • Reservoir sampling: a fair pick from a stream you cannot count
  • Expected time: why a random pivot makes quicksort safe
  • Skip list: coin flips instead of rebalancing
  • Treap: a search tree with random priorities

Terms it explains: fair shuffle, Fisher-Yates shuffle, Reservoir sampling, expected time, skip list, treap, Common mistakes, quickselect, binary search, binary-search-on-the-answer, comparison sort, counting/radix/bucket, external sort, heapsort, in-place, invariant, merge sort, pivot/partition, quicksort, stable sort, the O(n log n) wall, Timsort/introsort.

Review DSA