DSA and problem solving

Stage 1 of 8 · 6 lessons · ~3 weeks

Complexity and Big-O

Learn to say what a piece of code costs in time and memory before you run it. Every later stage is about trading one cost for another, so this is the vocabulary for all of it.

Start: What Big-O means and the common growth rates

Lessons· one lesson for each topic, in this order

  1. 1What Big-O means and the common growth rates
  2. 2Counting operations in loops
  3. 3Best, worst and average case
  4. 4Space complexity and the call stack
  5. 5Amortised cost
  6. 6Reading constraints to guess the target complexity

Start with· follow one of these

  • CoursePaid
    Grokking Algorithm Complexity and Big-O

    Design Gurus · Beginner · Subscription

    Short course on exactly this stage, including the amortised and space cases people miss

  • CourseFree
    Algorithms, Part I

    Princeton University · Intermediate

    Free: the Analysis of Algorithms module measures real Java programs, then models their cost

Keep handy

Also worth your time

Before moving on: Take 10 of your own past solutions, write the time and space complexity of each, then time them on inputs of 1,000, 10,000 and 100,000 items and check the growth matches your analysis.

Tauseef's advice
Learn to count the loops in your own code instead of memorising a table, and always ask what happens to the call stack in recursion. If syntax in your language still slows you down, do the Programming foundations roadmap first, because DSA on shaky syntax is twice as slow.

Mark this stage as not done?