Orders of growth are designed to simplify the analysis and comparison of computational processes. Many different processes can all have equivalent orders of growth, which indicates that they scale in similar ways. It is an essential skill of a computer scientist to know and recognize common orders of growth and identify processes of the same order.
    Constants. Constant terms do not affect the order of growth of a process. So, for instance, 2.8.5   Growth Categories - 图1 and 2.8.5   Growth Categories - 图2 are the same order of growth. This property follows from the definition of theta notation, which allows us to choose arbitrary constants 2.8.5   Growth Categories - 图3 and 2.8.5   Growth Categories - 图4 (such as 2.8.5   Growth Categories - 图5) for the upper and lower bounds. For simplicity, constants are always omitted from orders of growth.
    Logarithms. The base of a logarithm does not affect the order of growth of a process. For instance, 2.8.5   Growth Categories - 图6 and 2.8.5   Growth Categories - 图7 are the same order of growth. Changing the base of a logarithm is equivalent to multiplying by a constant factor.
    Nesting. When an inner computational process is repeated for each step in an outer process, then the order of growth of the entire process is a product of the number of steps in the outer and inner processes.
    For example, the function overlap below computes the number of elements in list a that also appear in list b.

    1. >>> def overlap(a, b):
    2. count = 0
    3. for item in a:
    4. if item in b:
    5. count += 1
    6. return count
    7. >>> overlap([1, 3, 2, 2, 5, 1], [5, 4, 2])
    8. 3

    The in operator for lists requires 2.8.5   Growth Categories - 图8 time, where nn is the length of the list b. It is applied 2.8.5   Growth Categories - 图9 times, where 2.8.5   Growth Categories - 图10 is the length of the list a. The item in b expression is the inner process, and the for item in a loop is the outer process. The total order of growth for this function is 2.8.5   Growth Categories - 图11.
    Lower-order terms. As the input to a process grows, the fastest growing part of a computation dominates the total resources used. Theta notation captures this intuition. In a sum, all but the fastest growing term can be dropped without changing the order of growth.
    For instance, consider the one_more function that returns how many elements of a list a are one more than some other element of a. That is, in the list [3, 14, 15, 9], the element 15 is one more than 14, so one_more will return 1.

    >>> def one_more(a):
            return overlap([x-1 for x in a], a)
    >>> one_more([3, 14, 15, 9])
    1
    

    There are two parts to this computation: the list comprehension and the call to overlap. For a list a of length nn, list comprehension requires 2.8.5   Growth Categories - 图12 steps, while the call to overlap requires 2.8.5   Growth Categories - 图13 steps. The sum of steps is 2.8.5   Growth Categories - 图14, but this is not the simplest way of expressing the order of growth.
    2.8.5   Growth Categories - 图15 and 2.8.5   Growth Categories - 图16 are equivalent for any constant 2.8.5   Growth Categories - 图17 because the 2.8.5   Growth Categories - 图18 term will eventually dominate the total for any 2.8.5   Growth Categories - 图19. The fact that bounds must hold only for 2.8.5   Growth Categories - 图20 greater than some minimum 2.8.5   Growth Categories - 图21 establishes this equivalence. For simplicity, lower-order terms are always omitted from orders of growth, and so we will never see a sum within a theta expression.
    Common categories. Given these equivalence properties, a small set of common categories emerge to describe most computational processes. The most common are listed below from slowest to fastest growth, along with descriptions of the growth as the input increases. Examples for each category follow.
    image.png
    Other categories exist, such as the 2.8.5   Growth Categories - 图23 growth of count_factors. However, these categories are particularly common.
    Exponential growth describes many different orders of growth, because changing the base bb does affect the order of growth. For instance, the number of steps in our tree-recursive Fibonacci computation fib grows exponentially in its input nn. In particular, one can show that the nth Fibonacci number is the closest integer to
    image.png
    where ϕϕ is the golden ratio:
    image.png
    We also stated that the number of steps scales with the resulting value, and so the tree-recursive process requires 2.8.5   Growth Categories - 图26 steps, a function that grows exponentially with 2.8.5   Growth Categories - 图27.