2
Big-O Notation and Complexity Analysis
When analyzing the things our code does, we are interested in two things: time complexity and space complexity. Time complexity refers to how much time our code takes to run, and space complexity refers to how much additional memory our code requires.
Any code you will ever write will have a specific set of inputs that yields particular outputs. In an ideal world, we’d want your code to run as fast as possible and take up as little memory as possible in doing so.
However, the real world has its quirks, and your code might decide to take a leisurely stroll instead, depending on the size and characteristics of its input. While you can always glance at your wall clock to clock its performance for a specific ...
Get Absolute Beginner's Guide to Algorithms: A Practical Introduction to Data Structures and Algorithms in JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.