12.07.2015 Views

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

SHOW MORE
SHOW LESS
  • No tags were found...

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

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

588 Chap. 17 Limits <strong>to</strong> ComputationThis does not mean that a computer program cannot be written that works onspecial cases, possibly even on most programs that we would be interested in checking.For example, some C compilers will check if the control expression for awhile loop is a constant expression that evaluates <strong>to</strong> false. If it is, the compilerwill issue a warning that the while loop code will never be executed. However, itis not possible <strong>to</strong> write a computer program that can check for all input programswhether a specified line of code will be executed when the program is given somespecified input.Another unsolvable problem is whether a program contains a computer virus.The property “contains a computer virus” is a matter of behavior. Thus, it is notpossible <strong>to</strong> determine positively whether an arbitrary program contains a computervirus. Fortunately, there are many good heuristics for determining if a programis likely <strong>to</strong> contain a virus, <strong>and</strong> it is usually possible <strong>to</strong> determine if a programcontains a particular virus, at least for the ones that are now known. Real viruscheckers do a pretty good job, but, it will always be possible for malicious people<strong>to</strong> invent new viruses that no existing virus checker can recognize.17.4 Further ReadingThe classic text on the theory of N P-completeness is Computers <strong>and</strong> Intractability:A Guide <strong>to</strong> the Theory of N P-completeness by Garey <strong>and</strong> Johns<strong>to</strong>n [GJ79].The Traveling Salesman Problem, edited by Lawler et al. [LLKS85], discussesmany approaches <strong>to</strong> finding an acceptable solution <strong>to</strong> this particular N P-completeproblem in a reasonable amount of time.For more information about the Collatz function see “On the Ups <strong>and</strong> Downsof Hails<strong>to</strong>ne Numbers” by B. Hayes [Hay84], <strong>and</strong> “The 3x + 1 Problem <strong>and</strong> itsGeneralizations” by J.C. Lagarias [Lag85].For an introduction <strong>to</strong> the field of computability <strong>and</strong> impossible problems, seeDiscrete <strong>Structures</strong>, Logic, <strong>and</strong> Computability by James L. Hein [Hei03].17.5 Exercises17.1 Consider this algorithm for finding the maximum element in an array: Firstsort the array <strong>and</strong> then select the last (maximum) element. What (if anything)does this reduction tell us about the upper <strong>and</strong> lower bounds <strong>to</strong> the problemof finding the maximum element in a sequence? Why can we not reduceSORTING <strong>to</strong> finding the maximum element?17.2 Use a reduction <strong>to</strong> prove that squaring an n × n matrix is just as expensive(asymp<strong>to</strong>tically) as multiplying two n × n matrices.

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

Saved successfully!

Ooh no, something went wrong!