A Common-Sense Guide to Data Structures and Algorithms, Second Edition — Pragmatic Programmers (208 / 226)
These are the solutions to the exercises found in the section, Exercises.
- This is O(1). We can consider N to be the year passed into the function. But no matter what the year is, the algorithm doesn’t vary in how many steps it takes.
- This is O(N). For N elements in the array, the loop will run N times.