In words
What it is, why it matters, and what it is like.
Why am I learning this?
You need Big-O notation to predict how a program's speed will change as the amount of data it processes grows. Imagine you are building a system that retrieves documents from a database. If the database has 1,000 records, it might respond instantly. But if it grows to 1,000,000 records, will the response time double, or will it become unusable? Big-O gives you a quick way to answer that question without running tests on every possible data size. It is the tool that lets you compare two different methods for solving a problem and choose the one that remains fast as your users and their data expand. Without this understanding, you cannot judge why a simple loop nested inside another loop slows down so dramatically or how to select an approach that scales reliably.
The idea, in plain terms
Imagine you are a chef preparing meals for a party. The amount of time it takes you to cook depends on the number of guests. If you have to chop each vegetable for each guest, then doubling the guests doubles your chopping time. That is called linear growth: time grows in direct proportion to the number of guests. For example, if chopping vegetables for 10 guests takes 10 minutes, it will take roughly 20 minutes for 20 guests.
But consider a different task: arranging seating where you must compare every guest with every other guest to ensure compatibility. If you have 2 guests, you have 1 comparison. With 4 guests, you have 6 comparisons. With 8 guests, you have 28 comparisons. Doubling the number of guests more than doubles the work; it causes the work to grow much faster. This is quadratic growth.
Big-O notation is a way to describe this relationship between input size and time (or memory) without getting bogged down in exact details like 'the chef cooks at 3 miles per hour' or 'the kitchen has one stove.' It focuses on the shape of the curve as the input gets very large. It asks: if I double the input, what happens to the time?
If time doubles, we say it is O(n) — linear growth.
If time quadruples (roughly), we say it is O(n^2) — quadratic growth.
If time doesn't change at all regardless of input size, we say it is O(1) — constant time. That is the whole idea: it describes growth patterns, not absolute speed.
An analogy
Think of Big-O as the story of a photocopier in an office. Suppose you have a stack of pages to copy. If you copy each page one at a time, the time it takes is directly proportional to the number of pages: copying 10 pages might take 10 minutes, and copying 20 pages will take 20 minutes. That is linear growth, or O(n).
Now suppose instead of copying each page individually, you have to compare each page with every other page in the stack to check for identical content. With a stack of 10 pages, that requires checking 45 pairs. With a stack of 20 pages, that requires checking 190 pairs. Doubling the number of pages roughly quadruples the work required. That is quadratic growth, or O(n^2).
But there is a third scenario: you have a huge stack of pre-printed forms and you just need to find one specific blank sheet from a known location at the top. You always take the same 30 seconds to grab it, regardless of whether the stack has 10 pages or 10,000 pages. That is constant time, or O(1).
The photocopier analogy shows that Big-O is not about how fast the machine is (that is the constant factor) but about how the workload grows as the stack grows. One important limitation of this analogy is that real computer hardware has memory layers: sometimes a method that looks slower in theory is actually faster in practice because it fits into fast, small storage spaces called cache. So Big-O is a guide to the shape of the curve, not a guarantee of exact performance.
Definition
Big-O notation is a way to describe how the time or memory required by a procedure grows as the size of its input grows, ignoring fixed constants to focus on the dominant pattern of scaling.
Where this sits
This concept is the foundation for Algorithms and Complexity. It connects directly to Binary Search, a method that finds items in sorted lists by repeatedly halving the search area, achieving very fast performance known as logarithmic time. It also connects to Dynamic Programming, a technique that solves complex problems by breaking them into overlapping sub-problems to avoid redundant calculations.