




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





Analyzing Algorithms
Best: The first number is the biggest (10, 1, 2, 3). We never update currentMax inside the loop. This is roughly 5n operations. = 7n- o Big Oh notation We don't usually say "This algorithm takes 7n - 2 steps." We simplify it to its most important part. As n gets very large (millions or billions), the "-2" and the "7" don't matter as much as the “n." If an algorithm's time is proportional to n, we say it is O(n) (Linear time).If it has nested loops (a loop inside a loop), it is often O(n^2) (Quadratic time).
Theorem 1.
R 1. Order the following list of functions by the big-Oh notation. Group together (for example, by underlining) those functions that are big-Theta of one another.
a. 1/n,
a. loglogn, b. Sqrt(logn) c. log^2n
We say f(n) is O(g(n)) if two constants
So for c = 3, and n0 = 1, since 2^(n+1) <= c (2^n) for all n >= 1, then 2^(n+1) = O(2^n) R 1. So big O is upper bound,