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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

which assigns to an <strong>in</strong>put value n the product of n with itself three times. This<br />

function appears less frequently <strong>in</strong> the context of algorithm analysis than the<br />

constant, l<strong>in</strong>ear, <strong>and</strong> quadratic functions previously mentioned, but it does appear<br />

from time to time.<br />

Polynomials<br />

Interest<strong>in</strong>gly, the functions we have listed so far can be viewed as all be<strong>in</strong>g part of<br />

a larger class of functions, the polynomials.<br />

A polynomial function is a function of the form,<br />

f(n) = a 0 + a 1 n + a 2 n 2 + a 3 n 3 + … + a d n d ,<br />

where a 0 ,a 1 ,…,a d are constants, called the coefficients of the polynomial, <strong>and</strong> a d<br />

≠ 0. Integer d, which <strong>in</strong>dicates the highest power <strong>in</strong> the polynomial, is called the<br />

degree of the polynomial.<br />

For example, the follow<strong>in</strong>g functions are all polynomials:<br />

• f(n) = 2 + 5n + n 2<br />

• f(n) = 1 + n 3<br />

• f(n) = 1<br />

• f(n) = n<br />

• f(n) = n 2 .<br />

Therefore, we could argue that this book presents just four important functions<br />

used <strong>in</strong> algorithm analysis, but we will stick to say<strong>in</strong>g that there are seven, s<strong>in</strong>ce<br />

the constant, l<strong>in</strong>ear, <strong>and</strong> quadratic functions are too important to be lumped <strong>in</strong><br />

with other polynomials. Runn<strong>in</strong>g times that are polynomials with degree, d, are<br />

generally better than polynomial runn<strong>in</strong>g times with large degree.<br />

Summations<br />

A notation that appears aga<strong>in</strong> <strong>and</strong> aga<strong>in</strong> <strong>in</strong> the analysis of data structures <strong>and</strong><br />

algorithms is the summation, which is def<strong>in</strong>ed as follows:<br />

,<br />

219

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

Saved successfully!

Ooh no, something went wrong!