23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

where a <strong>and</strong> b are <strong>in</strong>tegers <strong>and</strong> a ≤ b. Summations arise <strong>in</strong> data structure <strong>and</strong><br />

algorithm analysis because the runn<strong>in</strong>g times of loops naturally give rise to<br />

summations.<br />

Us<strong>in</strong>g a summation, we can rewrite the formula of Proposition 4.3 as<br />

.<br />

Likewise, we can write a polynomial f(n) of degree d with coefficients a 0 , …, a d<br />

as<br />

.<br />

Thus, the summation notation gives us a shorth<strong>and</strong> way of express<strong>in</strong>g sums of<br />

<strong>in</strong>creas<strong>in</strong>g terms that have a regular structure.<br />

4.1.7 The Exponential Function<br />

Another function used <strong>in</strong> the analysis of algorithms is the exponential function,<br />

f(n) = b n ,<br />

where b is a positive constant, called the base, <strong>and</strong> the argument n is the exponent.<br />

That is, function f(n) assigns to the <strong>in</strong>put argument n the value obta<strong>in</strong>ed by<br />

multiply<strong>in</strong>g the base b by itself n times. In algorithm analysis, the most common<br />

base for the exponential function is b = 2. For <strong>in</strong>stance, if we have a loop that starts<br />

by perform<strong>in</strong>g one operation <strong>and</strong> then doubles the number of operations performed<br />

with each iteration, then the number of operations performed <strong>in</strong> the nth iteration is<br />

2 n . In addition, an <strong>in</strong>teger word conta<strong>in</strong><strong>in</strong>g n bits can represent all the nonnegative<br />

<strong>in</strong>tegers less than 2 n . Thus, the exponential function with base 2 is quite common.<br />

The exponential function will also be referred to as exponent function.<br />

We sometimes have other exponents besides n, however; hence, it is useful for us to<br />

know a few h<strong>and</strong>y rules for work<strong>in</strong>g with exponents. In particular, the follow<strong>in</strong>g<br />

exponent rules are quite helpful.<br />

Proposition 4.4 (Exponent Rules): Given positive <strong>in</strong>tegers a,b,<strong>and</strong><br />

c,we have<br />

1. (b a ) c = b ac<br />

2. b a b c = b a+c<br />

3. b a /b c = b a − c .<br />

220

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!