Stage 4 · Lesson 1 of 10
Big-O time complexity
describes time complexity: how the work your code does grows as its input gets bigger, ignoring fixed constants. One over n items is O(n). A loop inside a loop over the same items is O(n²).
Reading an item by its index is O(1), meaning the same cost at any size. Halving the problem at each step is O(log n). The differences are huge in practice.
At 100,000 items, an O(n²) solution does about 10 billion steps, while an O(n) one does 100,000. Learn this first in the stage, because every structure that follows is best understood by what its operations cost. Count the loops in your own code, and watch for hidden loops inside built-in calls, such as searching a list.
A question to check yourself, an AI practice session and 1 cheat sheet entry come when you add the roadmap to your account. Add it
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking Data Structures & Algorithms for Coding Interviews
Design Gurus · Beginner · Subscription
Each structure built from first principles, with solutions in Python, Java, C++, JavaScript and C#
- CourseFreeCS50: Introduction to Computer Science
Harvard University · Beginner
Free: weeks 3 and 5 cover searching, sorting, linked lists, hash tables and trees
Practise
Keep handy
Also worth your time
Time and space complexity worked through five common algorithms