Data Structures and Algorithms with Object-Oriented Design Patterns in Python
next up previous index

Properties of Big Oh

In this section we examine some of the mathematical properties of big oh. In particular, suppose we know that tex2html_wrap_inline58677 and tex2html_wrap_inline58679.

The first theorem addresses the asymptotic behavior of the sum of two functions whose asymptotic behaviors are known:

Theorem  If tex2html_wrap_inline58677 and tex2html_wrap_inline58679, then

displaymath58665

extbfProof By Definition gif, there exist two integers, tex2html_wrap_inline58699 and tex2html_wrap_inline58701 and two constants tex2html_wrap_inline58703 and tex2html_wrap_inline58705 such that tex2html_wrap_inline58707 for tex2html_wrap_inline58709 and tex2html_wrap_inline58711 for tex2html_wrap_inline58713.

Let tex2html_wrap_inline58715 and tex2html_wrap_inline58717. Consider the sum tex2html_wrap_inline58719 for tex2html_wrap_inline58525:

eqnarray1463

Thus, tex2html_wrap_inline58723.

According to Theorem gif, if we know that functions tex2html_wrap_inline58681 and tex2html_wrap_inline58683 are tex2html_wrap_inline58729 and tex2html_wrap_inline58731, respectively, the sum tex2html_wrap_inline58719 is tex2html_wrap_inline58735. The meaning of tex2html_wrap_inline58737 is this context is the function h(n) where tex2html_wrap_inline58741 for integers all tex2html_wrap_inline58503.

For example, consider the functions tex2html_wrap_inline58745 and tex2html_wrap_inline58747. Then

eqnarray1468

Theorem gif helps us simplify the asymptotic analysis of the sum of functions by allowing us to drop the tex2html_wrap_inline58753 required by Theorem gif in certain circumstances:

Theorem  If tex2html_wrap_inline58755 in which tex2html_wrap_inline58681 and tex2html_wrap_inline58683 are both non-negative for all integers tex2html_wrap_inline58503 such that tex2html_wrap_inline58763 for some limit tex2html_wrap_inline58765, then tex2html_wrap_inline58767.

extbfProof According to the definition of limits , the notation

displaymath58666

means that, given any arbitrary positive value tex2html_wrap_inline58769, it is possible to find a value tex2html_wrap_inline58491 such that for all tex2html_wrap_inline58525

displaymath58667

Thus, if we chose a particular value, say tex2html_wrap_inline58775, then there exists a corresponding tex2html_wrap_inline58491 such that

eqnarray1488

Consider the sum tex2html_wrap_inline58755:

eqnarray1494

where tex2html_wrap_inline58781. Thus, tex2html_wrap_inline58767.

Consider a pair of functions tex2html_wrap_inline58681 and tex2html_wrap_inline58683, which are known to be tex2html_wrap_inline58729 and tex2html_wrap_inline58731, respectively. According to Theorem gif, the sum tex2html_wrap_inline58755 is tex2html_wrap_inline58735. However, Theorem gif says that, if tex2html_wrap_inline58797 exists, then the sum f(n) is simply tex2html_wrap_inline58801 which, by the transitive property (see Theorem gif below), is tex2html_wrap_inline58729.

In other words, if the ratio tex2html_wrap_inline58805 asymptotically approaches a constant as n gets large, we can say that tex2html_wrap_inline58719 is tex2html_wrap_inline58729, which is often a lot simpler than tex2html_wrap_inline58735.

Theorem gif is particularly useful result. Consider tex2html_wrap_inline58815 and tex2html_wrap_inline58627.

eqnarray1501

From this we can conclude that tex2html_wrap_inline58819. Thus, Theorem gif suggests that the sum of a series of powers of n is tex2html_wrap_inline58823, where m is the largest power of n in the summation. We will confirm this result in Section gif below.

The next theorem addresses the asymptotic behavior of the product of two functions whose asymptotic behaviors are known:

Theorem  If tex2html_wrap_inline58677 and tex2html_wrap_inline58679, then

displaymath58668

extbfProof By Definition gif, there exist two integers, tex2html_wrap_inline58699 and tex2html_wrap_inline58701 and two constants tex2html_wrap_inline58703 and tex2html_wrap_inline58705 such that tex2html_wrap_inline58707 for tex2html_wrap_inline58709 and tex2html_wrap_inline58711 for tex2html_wrap_inline58713. Furthermore, by Definition gif, tex2html_wrap_inline58681 and tex2html_wrap_inline58683 are both non-negative for all integers tex2html_wrap_inline58503.

Let tex2html_wrap_inline58715 and tex2html_wrap_inline58857. Consider the product tex2html_wrap_inline58859 for tex2html_wrap_inline58525:

eqnarray1521

Thus, tex2html_wrap_inline58863.

Theorem gif describes a simple, but extremely useful property of big oh. Consider the functions tex2html_wrap_inline58865 and tex2html_wrap_inline58867. By Theorem gif, the asymptotic behavior of the product tex2html_wrap_inline58859 is tex2html_wrap_inline58871. That is, we are able to determine the asymptotic behavior of the product without having to go through the gory details of calculating that tex2html_wrap_inline58873.

The next theorem is closely related to the preceding one in that it also shows how big oh behaves with respect to multiplication.

Theorem  If tex2html_wrap_inline58677 and tex2html_wrap_inline58691 is a function whose value is non-negative for integers tex2html_wrap_inline58503, then

displaymath58669

extbfProof By Definition gif, there exist integers tex2html_wrap_inline58491 and constant tex2html_wrap_inline58883 such that tex2html_wrap_inline58885 for tex2html_wrap_inline58525. Since tex2html_wrap_inline58691 is never negative,

displaymath58670

Thus, tex2html_wrap_inline58891.

Theorem gif applies when we multiply a function, tex2html_wrap_inline58681, whose asymptotic behavior is known to be tex2html_wrap_inline58729, by another function tex2html_wrap_inline58691. The asymptotic behavior of the result is simply tex2html_wrap_inline58899.

One way to interpret Theorem gif is that it allows us to do the following mathematical manipulation:

eqnarray1533

That is, Fallacy gif notwithstanding, we can multiply both sides of the ``equation'' by tex2html_wrap_inline58691 and the ``equality'' still holds. Furthermore, when we multiply tex2html_wrap_inline58729 by tex2html_wrap_inline58691, we simply bring the tex2html_wrap_inline58691 inside the tex2html_wrap_inline57621.

The last theorem in this section introduces the transitive property of big oh:

Theorem (Transitive Property)    If f(n)=O(g(n)) and g(n)=O(h(n)) then f(n)=O(h(n)).

extbfProof By Definition gif, there exist two integers, tex2html_wrap_inline58699 and tex2html_wrap_inline58701 and two constants tex2html_wrap_inline58703 and tex2html_wrap_inline58705 such that tex2html_wrap_inline58925 for tex2html_wrap_inline58709 and tex2html_wrap_inline58929 for tex2html_wrap_inline58713.

Let tex2html_wrap_inline58715 and tex2html_wrap_inline58857. Then

eqnarray1544

Thus, f(n)=O(h(n)).

The transitive property of big oh is useful in conjunction with Theorem gif. Consider tex2html_wrap_inline58939 which is clearly tex2html_wrap_inline58941. If we add to tex2html_wrap_inline58681 the function tex2html_wrap_inline58945, then by Theorem gif, the sum tex2html_wrap_inline58719 is tex2html_wrap_inline58801 because tex2html_wrap_inline58951. That is, tex2html_wrap_inline58953. The combination of the fact that tex2html_wrap_inline58955 and the transitive property of big oh, allows us to conclude that the sum is tex2html_wrap_inline58941.


next up previous index

Bruno Copyright © 2003, 2004 by Bruno R. Preiss, P.Eng. All rights reserved.