Esc
  • Loading…
↑ ↓ to moveEnter to openEsc to close

Sorting

See how every classic sorting algorithm works, step by step, then use sorting to crack the interview questions where putting things in order is the whole trick.

  • 8 Lessons
  • 16 Problems
  • 46 Illustrations

What you will learn

  • What sorting is, and what stable, in-place and comparison-based mean
  • How bubble, selection, insertion, merge, quick, counting and radix sort work — each drawn and in a simulator
  • The time and space of every algorithm, and why no comparison sort beats O(n log n)
  • Which algorithm your language's built-in sort uses, and when to write your own
  • 4 sorting patterns: sort then scan, custom comparators, counting and partitioning, and merge sort tricks
  • The sorting interview questions asked most, from Contains Duplicate to Reverse Pairs

Why this course

Sorting is the most used algorithm in programming, and one of the most useful tricks in interviews: once data is in order, duplicates sit next to each other, intervals line up, and a binary search or two pointers can finish the job.

The introduction shows how each sorting algorithm works — bubble, selection, insertion, merge, quick, counting and radix — with a drawing and a simulator for every one, the cost of each, and how to choose between them.

Then come 4 patterns, from easiest to hardest, each taught through the interview questions that use it, with code in four languages, the complexity of every approach and a simulator you can step through.

Requirements

  • Comfort writing loops, conditionals and functions in at least one language
  • The Arrays course, or equivalent familiarity with indexes and swapping
  • Recursion helps for merge sort and quick sort — it's explained as we go

Course Contents