- Tutorials
- DSA Tutorial
- Big O and Complexity
Big O and Complexity
3 lessonsAbout 18 minutesBeginner
This part of the DSA Tutorial runs from Big O Notation Explained through to Amortised Analysis. There are 3 lessons here, and working through them takes about 18 minutes at a steady pace.
It follows on from DSA Introduction, so finish that first if you have not already — the examples below assume you are comfortable with it.
Each lesson below says what it covers before you open it. Read them in order the first time; afterwards this page works as a index you can jump back into when you need to check one thing.
- 1Big O Notation ExplainedBig O describes how an algorithm slows down as input grows, not how many milliseconds it takes. Learn to read O(1), O(n), O(n log n) and O(n²) from JavaScript code.
- 2Time vs Space ComplexityTime complexity counts operations; space complexity counts memory. Learn to measure both in JavaScript and recognise when trading one for the other is worth it.
- 3Amortised AnalysisWhy push is called O(1) when it sometimes copies the whole array. Learn amortised analysis in JavaScript and the difference between an average case and an amortised one.
