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 19 min to read

Play it as a journeyTutor comes with a plan

Sorting & Searching

Sorting and Searching
Sorting and Searching · Open board

A pile of four numbers split around one of them and put back together in order, then a search that opens straight to the middle of a sorted pile instead of reading it from the start.

Before you start. You need an index, a position in a list, counted from zero, and what Complexity & Big-O already gave you: that doubling the input can double the work, or square it, or barely change it, depending on the method. Everything else here, splitting a pile around one number, and opening a sorted pile at the middle, is new.

Lesson 8 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

  • 1959: a dictionary on tape, and no time to read it start to finish
  • Moscow: split the pile around one word
  • Do it again, on each pile
  • Twenty comparisons, not a million: what splitting buys
  • 1960: a bet in London
  • The reward: flip to the middle, not the first page
  • The n log n wall, and how to dodge it
  • Binary search, formally
  • Classic pitfalls

Terms it explains: pivot, partition, recursion, binary search, merge sort, merge, Heap sort, Insertion sort, Merge sort, traced, Stability, last, monotonic, shuffle, binary-search-on-the-answer, comparison sort, counting/radix/bucket, external sort, heapsort, in-place, invariant, pivot/partition, quicksort, stable sort, the O(n log n) wall, Timsort/introsort.

Review DSA