A Common-Sense Guide to Data Structures and Algorithms, Second Edition, 2nd Edition
by Jay Wengrow
Chapter 7Big O in Everyday Code
In the previous chapters, you learned how to use Big O notation to express the time complexity of code. As you’ve seen, there are quite a few details that go into Big O analysis. In this chapter, we’ll use everything you’ve learned so far to analyze the efficiency of practical code samples that might be found in real-world codebases.
Determining the efficiency of our code is the first step in optimizing it. After all, if we don’t know how fast our code is, how would we know if our modifications would make it faster?
Additionally, once we know how our code is categorized in terms of Big O Notation, we can make a judgment call as to whether it may need optimization in the first place. For example, an algorithm that ...
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