Algorithms & Complexity
Don't do this
3 Big-O mistakes that cost you marks
3 mistakes that cost marks in Big-O questions
Quick check · tap an answer to continue
Lesson notes
Key points
- Keeping constants: Writing O(2n + 5) loses marks; drop constants and lower terms, so the answer is simply O(n).
- Adding nested loops: Nested loops over n multiply, not add, so two nested n loops give O(n²), not O(2n).
- Ignoring recursion depth: Recursive Fibonacci branches twice per call, giving exponential O(2ⁿ) time; draw the recursion tree before answering.
Takeaway: Drop constants, multiply nested loops, draw recursion trees.
Quick check: What is the time complexity of two nested loops each running n times?
- O(2n)
- O(n²)
- O(n log n)
Inner loop runs n times for each of n outer iterations: n × n.
Lessons like this, for your syllabus.
Short narrated study videos written for your course, level and exam. Free to start.
Get lessons for your own syllabus