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.

Efficiency<br />

Next: Expressing <strong>Algorithm</strong>s Up: Correctness and Efficiency Previous: Correctness<br />

Efficiency<br />

<strong>The</strong> skilled algorithm designer is an efficiency expert. Through cunning and experience we seek to get<br />

jobs done as quickly as possible. <strong>The</strong> benefits of finding an efficient algorithm for a computationally<br />

expensive job can be mind-boggling, as illustrated by several of the war stories scattered through this<br />

book. Section shows how clever algorithms yielded a program that was 30,000 times faster than our<br />

initial attempt!<br />

Upon realizing that a given application runs too slowly, the practical person usually asks the boss to buy<br />

them a faster machine. Sometimes this is the cheapest option. However, the potential win from faster<br />

hardware is typically limited to a factor of ten or so, due to technical constraints (they don't make faster<br />

machines) or economic ones (the boss won't pay for it).<br />

To realize larger performance improvements, we must seek better algorithms. As we will show, a faster<br />

algorithm running on a slower computer will always win for sufficiently large instances. Always.<br />

Usually, problems don't have to get very large before the faster algorithm wins.<br />

Be aware that there are situations where finding the most efficient algorithm for a job is a complete waste<br />

of programmer effort. In any program, there is usually one bottleneck that takes the majority of<br />

computing time. <strong>The</strong> typical claim is that 90% of the run time of any program is spent in 10% of the<br />

code. Optimizing the other 90% of the program will have little impact on the total run time. Further,<br />

many programs are written with only one or two special instances in mind. If the program will be run just<br />

a few times, or if the job can easily be run overnight, it probably does not pay to make the programmer<br />

work harder in order to reduce cycle consumption.<br />

Next: Expressing <strong>Algorithm</strong>s Up: Correctness and Efficiency Previous: Correctness<br />

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

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

file:///E|/BOOK/BOOK/NODE9.HTM [19/1/2003 1:28:06]

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

Saved successfully!

Ooh no, something went wrong!