Logo Data Structures and Algorithms with Object-Oriented Design Patterns in C++
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_inline59227 and tex2html_wrap_inline59229.

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

Theorem  If tex2html_wrap_inline59227 and tex2html_wrap_inline59229, then

displaymath59215

extbfProof By Definition gif, there exist two integers, tex2html_wrap_inline59249 and tex2html_wrap_inline59251 and two constants tex2html_wrap_inline59253 and tex2html_wrap_inline59255 such that tex2html_wrap_inline59257 for tex2html_wrap_inline59259 and tex2html_wrap_inline59261 for tex2html_wrap_inline59263.

Let tex2html_wrap_inline59265 and tex2html_wrap_inline59267. Consider the sum tex2html_wrap_inline59269 for tex2html_wrap_inline59075:

eqnarray1403

Thus, tex2html_wrap_inline59273.

According to Theorem gif, if we know that functions tex2html_wrap_inline59231 and tex2html_wrap_inline59233 are tex2html_wrap_inline59279 and tex2html_wrap_inline59281, respectively, the sum tex2html_wrap_inline59269 is tex2html_wrap_inline59285. The meaning of tex2html_wrap_inline59287 is this context is the function h(n) where tex2html_wrap_inline59291 for integers all tex2html_wrap_inline59063.

For example, consider the functions tex2html_wrap_inline59295 and tex2html_wrap_inline59297. Then

eqnarray1408

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

Theorem  If tex2html_wrap_inline59305 in which tex2html_wrap_inline59231 and tex2html_wrap_inline59233 are both non-negative for all integers tex2html_wrap_inline59063 such that tex2html_wrap_inline59313 for some limit tex2html_wrap_inline59315, then tex2html_wrap_inline59317.

extbfProof According to the definition of limits , the notation

displaymath59216

means that, given any arbitrary positive value tex2html_wrap_inline59319, it is possible to find a value tex2html_wrap_inline59043 such that for all tex2html_wrap_inline59075

displaymath59217

Thus, if we chose a particular value, say tex2html_wrap_inline59325, then there exists a corresponding tex2html_wrap_inline59043 such that

eqnarray1426

Consider the sum tex2html_wrap_inline59305:

eqnarray1430

where tex2html_wrap_inline59331. Thus, tex2html_wrap_inline59317.

Consider a pair of functions tex2html_wrap_inline59231 and tex2html_wrap_inline59233, which are known to be tex2html_wrap_inline59279 and tex2html_wrap_inline59281, respectively. According to Theorem gif, the sum tex2html_wrap_inline59305 is tex2html_wrap_inline59285. However, Theorem gif says that, if tex2html_wrap_inline59347 exists, then the sum f(n) is simply tex2html_wrap_inline59351 which, by the transitive property (see Theorem gif below), is tex2html_wrap_inline59279.

In other words, if the ratio tex2html_wrap_inline59355 asymptotically approaches a constant as n gets large, we can say that tex2html_wrap_inline59269 is tex2html_wrap_inline59279, which is often a lot simpler than tex2html_wrap_inline59285.

Theorem gif is particularly useful result. Consider tex2html_wrap_inline59365 and tex2html_wrap_inline59177.

eqnarray1437

From this we can conclude that tex2html_wrap_inline59369. Thus, Theorem gif suggests that the sum of a series of powers of n is tex2html_wrap_inline59373, 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_inline59227 and tex2html_wrap_inline59229, then

displaymath59218

extbfProof By Definition gif, there exist two integers, tex2html_wrap_inline59249 and tex2html_wrap_inline59251 and two constants tex2html_wrap_inline59253 and tex2html_wrap_inline59255 such that tex2html_wrap_inline59257 for tex2html_wrap_inline59259 and tex2html_wrap_inline59261 for tex2html_wrap_inline59263. Furthermore, by Definition gif, tex2html_wrap_inline59231 and tex2html_wrap_inline59233 are both non-negative for all integers tex2html_wrap_inline59063.

Let tex2html_wrap_inline59265 and tex2html_wrap_inline59407. Consider the product tex2html_wrap_inline59409 for tex2html_wrap_inline59075:

eqnarray1455

Thus, tex2html_wrap_inline59413.

Theorem gif describes a simple, but extremely useful property of big oh. Consider the functions tex2html_wrap_inline59415 and tex2html_wrap_inline59417. By Theorem gif, the asymptotic behavior of the product tex2html_wrap_inline59409 is tex2html_wrap_inline59421. I.e., we are able to determine the asymptotic behavior of the product without having to go through the gory details of calculating that tex2html_wrap_inline59423.

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_inline59227 and tex2html_wrap_inline59241 is a function whose value is non-negative for integers tex2html_wrap_inline59063, then

displaymath59219

extbfProof By Definition gif, there exist integers tex2html_wrap_inline59043 and constant tex2html_wrap_inline59433 such that tex2html_wrap_inline59435 for tex2html_wrap_inline59075. Since tex2html_wrap_inline59241 is never negative,

displaymath59220

Thus, tex2html_wrap_inline59441.

Theorem gif applies when we multiply a function, tex2html_wrap_inline59231, whose asymptotic behavior is known to be tex2html_wrap_inline59279, by another function tex2html_wrap_inline59241. The asymptotic behavior of the result is simply tex2html_wrap_inline59449.

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

eqnarray1467

I.e., Fallacy gif notwithstanding, we can multiply both sides of the ``equation'' by tex2html_wrap_inline59241 and the ``equality'' still holds. Furthermore, when we multiply tex2html_wrap_inline59279 by tex2html_wrap_inline59241, we simply bring the tex2html_wrap_inline59241 inside the tex2html_wrap_inline58163.

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_inline59249 and tex2html_wrap_inline59251 and two constants tex2html_wrap_inline59253 and tex2html_wrap_inline59255 such that tex2html_wrap_inline59475 for tex2html_wrap_inline59259 and tex2html_wrap_inline59479 for tex2html_wrap_inline59263.

Let tex2html_wrap_inline59265 and tex2html_wrap_inline59407. Then

eqnarray1478

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

The transitive property of big oh is useful in conjunction with Theorem gif. Consider tex2html_wrap_inline59489 which is clearly tex2html_wrap_inline59491. If we add to tex2html_wrap_inline59231 the function tex2html_wrap_inline59495, then by Theorem gif, the sum tex2html_wrap_inline59269 is tex2html_wrap_inline59351 because tex2html_wrap_inline59501. I.e., tex2html_wrap_inline59503. The combination of the fact that tex2html_wrap_inline59505 and the transitive property of big oh, allows us to conclude that the sum is tex2html_wrap_inline59491.


next up previous contents index

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