Chapter 2. The Universal Language of Algorithm Performance: Big O
Your search is fast now. But the real question is, will it stay fast as the input data doubles? Or triples? Or grows to a million?
One way that helps us think about this is the algorithms’ growth curve. Some seem to climb gently, while others explode upward. But how do we actually talk about those curves? We need a vocabulary. How do we describe the difference between an algorithm that scales well as input grows, and one that gets you into trouble?
That’s where Big O comes in. Big O doesn’t care about your processor or your RAM. It cares about how your algorithm behaves, especially when your algorithm is under pressure.
In this chapter, we’ll get comfortable with Big O: how to read it, how to write it, and (yes) how to actually understand it. You won’t need to understand dense formulas (just the opposite), and no math degree is required.
The payoff? Learning how to describe the efficiency of an algorithm using a simple formula, which will unlock a whole new way of reasoning about performance, no matter your language or platform of choice.
By the end, you won’t just understand Big O, you’ll think in it. Let’s go.
Say hello to Big O
So, how do we describe how fast (or slow) an algorithm is?
Meet Big O notation. It’s the universal shorthand for describing how an algorithm’s performance scales with input size. You ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access