Lecture 02: Practice Problems

1. True or False?

2^(n+1) = O(2^n)

Show Answer

True.

2^(n+1) = 2 * 2^n. This is just a constant factor (c=2) times 2^n.

2. True or False?

2^(2n) = O(2^n)

Show Answer

False.

2^(2n) = (2^n)^2 = 4^n.

4^n grows much faster than 2^n.

3. Ranking Functions

Rank the following from slowest growth to fastest growth:

n + log n, n log n, n, n^2, 100.

Show Answer
  1. 100 (Constant)
  2. n (Linear) -- Note: n + log n is dominated by n.
  3. n log n (Linearithmic)
  4. n^2 (Quadratic)