What is a plain English explanation of "Big O" notation?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
"Big O" notation is a way to describe how the performance or running time of an algorithm changes as the size of the input grows. It gives you an idea of the efficiency of an algorithm in terms of time or space, helping you understand how well it scales.
Imagine This Scenario
Suppose you're baking cookies and you have a recipe that takes a certain amount of time to prepare, depending on how many cookies you want to make. If you only make a few cookies, the preparation time is quick, but if you make a lot of cookies, the preparation time increases.
Big O in Baking
- If your recipe takes exactly the same amount of time to prepare no matter how many cookies you make, we could describe it as O(1). This means it's a "constant time" recipe.
- If your recipe takes twice as long when you double the number of cookies, we could describe it as O(n). This means it's a "linear time" recipe where the time grows directly in proportion to the number of cookies.
- If your recipe's time increases more rapidly as you make more cookies, say, it takes four times longer when you double the number of cookies, we might describe it as O(n^2). This means it's a "quadratic time" recipe, where the time grows much faster as the number of cookies increases.
Big O in Computer Algorithms
In computing, instead of cookies, we're often dealing with data like numbers, text, or other inputs. Big O notation helps describe how the time or space required by an algorithm grows as the size of the input data increases:
- O(1): The algorithm takes the same time regardless of input size (e.g., looking up a single item in a list by index).
- O(n): The time grows linearly with the input size (e.g., finding an item in an unsorted list by checking each item).
- O(log n): The time grows logarithmically, meaning it increases slowly as the input size increases (e.g., binary search in a sorted list).
- O(n^2): The time grows quadratically, meaning it increases rapidly as the input size increases (e.g., comparing every pair of items in a list).
- O(2^n): The time doubles with each additional input element (e.g., certain types of recursive algorithms).
Why It Matters
Understanding Big O notation helps you choose the right algorithm for your problem, especially as the amount of data increases. An algorithm that works well with small amounts of data might become too slow with larger datasets if it has a poor Big O performance.
In summary, Big O notation is a way to express the efficiency of an algorithm by describing how the time or space requirements grow as the input size increases. It helps you anticipate how an algorithm will perform as the problem size scales up.

