Cover Data Structures and Algorithms with Object-Oriented Design Patterns in Java
next up previous contents 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_inline58170 and tex2html_wrap_inline58172.

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

Theorem  If tex2html_wrap_inline58170 and tex2html_wrap_inline58172, then

displaymath58158

extbfProof By Definition gif, there exist two integers, tex2html_wrap_inline58192 and tex2html_wrap_inline58194 and two constants tex2html_wrap_inline58196 and tex2html_wrap_inline58198 such that tex2html_wrap_inline58200 for tex2html_wrap_inline58202 and tex2html_wrap_inline58204 for tex2html_wrap_inline58206.

Let tex2html_wrap_inline58208 and tex2html_wrap_inline58210. Consider the sum tex2html_wrap_inline58212 for tex2html_wrap_inline58018:

eqnarray1474

Thus, tex2html_wrap_inline58216.

According to Theorem gif, if we know that functions tex2html_wrap_inline58174 and tex2html_wrap_inline58176 are tex2html_wrap_inline58222 and tex2html_wrap_inline58224, respectively, the sum tex2html_wrap_inline58212 is tex2html_wrap_inline58228. The meaning of tex2html_wrap_inline58230 is this context is the function h(n) where tex2html_wrap_inline58234 for integers all tex2html_wrap_inline57996.

For example, consider the functions tex2html_wrap_inline58238 and tex2html_wrap_inline58240. Then

eqnarray1479

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

Theorem  If tex2html_wrap_inline58248 in which tex2html_wrap_inline58174 and tex2html_wrap_inline58176 are both non-negative for all integers tex2html_wrap_inline57996 such that tex2html_wrap_inline58256 for some limit tex2html_wrap_inline58258, then tex2html_wrap_inline58260.

extbfProof According to the definition of limits , the notation

displaymath58159

means that, given any arbitrary positive value tex2html_wrap_inline58262, it is possible to find a value tex2html_wrap_inline57984 such that for all tex2html_wrap_inline58018

displaymath58160

Thus, if we chose a particular value, say tex2html_wrap_inline58268, then there exists a corresponding tex2html_wrap_inline57984 such that

eqnarray1499

Consider the sum tex2html_wrap_inline58248:

eqnarray1505

where tex2html_wrap_inline58274. Thus, tex2html_wrap_inline58260.

Consider a pair of functions tex2html_wrap_inline58174 and tex2html_wrap_inline58176, which are known to be tex2html_wrap_inline58222 and tex2html_wrap_inline58224, respectively. According to Theorem gif, the sum tex2html_wrap_inline58248 is tex2html_wrap_inline58228. However, Theorem gif says that, if tex2html_wrap_inline58290 exists, then the sum f(n) is simply tex2html_wrap_inline58294 which, by the transitive property (see Theorem gif below), is tex2html_wrap_inline58222.

In other words, if the ratio tex2html_wrap_inline58298 asymptotically approaches a constant as n gets large, we can say that tex2html_wrap_inline58212 is tex2html_wrap_inline58222, which is often a lot simpler than tex2html_wrap_inline58228.

Theorem gif is particularly useful result. Consider tex2html_wrap_inline58308 and tex2html_wrap_inline58120.

eqnarray1512

From this we can conclude that tex2html_wrap_inline58312. Thus, Theorem gif suggests that the sum of a series of powers of n is tex2html_wrap_inline58316, 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_inline58170 and tex2html_wrap_inline58172, then

displaymath58161

extbfProof By Definition gif, there exist two integers, tex2html_wrap_inline58192 and tex2html_wrap_inline58194 and two constants tex2html_wrap_inline58196 and tex2html_wrap_inline58198 such that tex2html_wrap_inline58200 for tex2html_wrap_inline58202 and tex2html_wrap_inline58204 for tex2html_wrap_inline58206. Furthermore, by Definition gif, tex2html_wrap_inline58174 and tex2html_wrap_inline58176 are both non-negative for all integers tex2html_wrap_inline57996.

Let tex2html_wrap_inline58208 and tex2html_wrap_inline58350. Consider the product tex2html_wrap_inline58352 for tex2html_wrap_inline58018:

eqnarray1532

Thus, tex2html_wrap_inline58356.

Theorem gif describes a simple, but extremely useful property of big oh. Consider the functions tex2html_wrap_inline58358 and tex2html_wrap_inline58360. By Theorem gif, the asymptotic behavior of the product tex2html_wrap_inline58352 is tex2html_wrap_inline58364. 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_inline58366.

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_inline58170 and tex2html_wrap_inline58184 is a function whose value is non-negative for integers tex2html_wrap_inline57996, then

displaymath58162

extbfProof By Definition gif, there exist integers tex2html_wrap_inline57984 and constant tex2html_wrap_inline58376 such that tex2html_wrap_inline58378 for tex2html_wrap_inline58018. Since tex2html_wrap_inline58184 is never negative,

displaymath58163

Thus, tex2html_wrap_inline58384.

Theorem gif applies when we multiply a function, tex2html_wrap_inline58174, whose asymptotic behavior is known to be tex2html_wrap_inline58222, by another function tex2html_wrap_inline58184. The asymptotic behavior of the result is simply tex2html_wrap_inline58392.

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

eqnarray1544

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

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_inline58192 and tex2html_wrap_inline58194 and two constants tex2html_wrap_inline58196 and tex2html_wrap_inline58198 such that tex2html_wrap_inline58418 for tex2html_wrap_inline58202 and tex2html_wrap_inline58422 for tex2html_wrap_inline58206.

Let tex2html_wrap_inline58208 and tex2html_wrap_inline58350. Then

eqnarray1555

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

The transitive property of big oh is useful in conjunction with Theorem gif. Consider tex2html_wrap_inline58432 which is clearly tex2html_wrap_inline58434. If we add to tex2html_wrap_inline58174 the function tex2html_wrap_inline58438, then by Theorem gif, the sum tex2html_wrap_inline58212 is tex2html_wrap_inline58294 because tex2html_wrap_inline58444. That is, tex2html_wrap_inline58446. The combination of the fact that tex2html_wrap_inline58448 and the transitive property of big oh, allows us to conclude that the sum is tex2html_wrap_inline58434.


next up previous contents index

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