DSA and problem solving

Stage 1 · Lesson 3 of 6

Best, worst and average case

Complexity and Big-O

The same algorithm can do very different amounts of work on two inputs of the same size. The is the most work it does on any input. The best case is the least, and the average case is what you expect on typical or random input.

, which checks items one by one, finds its target on the first step at best and checks everything at worst. averages O(n log n) but slows to O(n²) when it keeps choosing bad split points (). When someone gives one without saying which case, they almost always mean the worst. That is the case that decides whether your code finishes on the input you did not expect.

A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

Keep handy

Also worth your time

Mark this stage as not done?