18.04.2013 Views

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Expressing <strong>Algorithm</strong>s<br />

Next: Keeping Score Up: Introduction to <strong>Algorithm</strong>s Previous: Efficiency<br />

Expressing <strong>Algorithm</strong>s<br />

Describing algorithms requires a notation for expressing a sequence of steps to be performed. <strong>The</strong> three<br />

most common options are (1) English, (2) pseudocode, or (3) a real programming language. Pseudocode<br />

is perhaps the most mysterious of the bunch, but it is best defined as a programming language that never<br />

complains about syntax errors. All three methods can be useful in certain circumstances, since there is a<br />

natural tradeoff between greater ease of expression and precision. English is the most natural but least<br />

precise language, while C and Pascal are precise but difficult to write and understand. Pseudocode is<br />

useful because it is a happy medium.<br />

<strong>The</strong> correct choice of which notation is best depends upon which of the three methods you are most<br />

comfortable with. I prefer to describe the ideas of an algorithm in English, moving onto a more formal,<br />

programming-language-like pseudocode to clarify sufficiently tricky details of the algorithm. A common<br />

mistake among my students is to use pseudocode to take an ill-defined idea and dress it up so that it looks<br />

more formal. In the real world, you only fool yourself when you pull this kind of stunt.<br />

<strong>The</strong> implementation complexity of an algorithm is usually why the fastest algorithm known for a problem<br />

may not be the most appropriate for a given application. An algorithm's implementation complexity is<br />

often a function of how it has been described. Fast algorithms often make use of very complicated data<br />

structures, or use other complicated algorithms as subroutines. Turning these algorithms into programs<br />

requires building implementations of every substructure. Each catalog entry in Section points out<br />

available implementations of algorithms to solve the given problem. Hopefully, these can be used as<br />

building blocks to reduce the implementation complexity of algorithms that use them, thus making more<br />

complicated algorithms worthy of consideration in practice.<br />

Next: Keeping Score Up: Introduction to <strong>Algorithm</strong>s Previous: Efficiency<br />

<strong>Algorithm</strong>s<br />

Mon Jun 2 23:33:50 EDT 1997<br />

file:///E|/BOOK/BOOK/NODE10.HTM [19/1/2003 1:28:07]

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

Saved successfully!

Ooh no, something went wrong!