Chapter 5
These are the solutions to the exercises found in the section Exercises.
-
After dropping the constants, we can reduce the expression to O(N).
-
After dropping the constant, we can reduce the expression to O(N2).
-
This algorithm is one of O(N), with N being the size of the array. While there are two distinct loops that process the N elements, this is simply 2N, which is reduced to O(N) after dropping the constants.
-
This algorithm is one of O(N), with N being the size of the array. Within the loop, we run three steps, which means our algorithm takes 3N steps. However, this is reduced to O(N) when we eliminate the constants.
-
This algorithm is one of O(N2), with N being the size of the array. While we only run the inner loop half of the time, ...
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