Definition

Function r has order of growth if there are positive constants and and a number such that for all

Explanation

  • Specifies the asymptotic bounds (both upper and lower) for a function
  • Can be thought of as the average time/space complexity of an algorithm

For CS1101s

  1. Identify the basic computational steps
    • Can be thought of as number of function calls in the case of recursive functions (not recursive processes)
  2. Try a few small values
  3. Extrapolate
  4. Watch out for β€œworst case” scenarios
    • We do not necessarily need to include these scenarios due to

Some Examples

FunctionTime ComplexitySpace Complexity
factorial (recursive)
factorial (iterative)
fibonacci (recursive)
fibonacci (iterative)??