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...

Create successful ePaper yourself

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

560 Chap. 17 Limits <strong>to</strong> Computationslow, but perhaps there are better ones waiting <strong>to</strong> be discovered. Of course, whilehaving a problem with high running time is bad, it is even worse <strong>to</strong> have a problemthat cannot be solved at all! Problems of the later type do exist, <strong>and</strong> some arepresented in Section 17.3.This chapter presents a brief introduction <strong>to</strong> the theory of expensive <strong>and</strong> impossibleproblems. Section 17.1 presents the concept of a reduction, which is thecentral <strong>to</strong>ol used for analyzing the difficulty of a problem (as opposed <strong>to</strong> analyzingthe cost of an algorithm). Reductions allow us <strong>to</strong> relate the difficulty of variousproblems, which is often much easier than doing the analysis for a problem fromfirst principles. Section 17.2 discusses “hard” problems, by which we mean problemsthat require, or at least appear <strong>to</strong> require, time exponential on the input size.Finally, Section 17.3 considers various problems that, while often simple <strong>to</strong> define<strong>and</strong> comprehend, are in fact impossible <strong>to</strong> solve using a computer program. Theclassic example of such a problem is deciding whether an arbitrary computer programwill go in<strong>to</strong> an infinite loop when processing a specified input. This is knownas the halting problem.17.1 ReductionsWe begin with an important concept for underst<strong>and</strong>ing the relationships betweenproblems, called reduction. Reduction allows us <strong>to</strong> solve one problem in termsof another. Equally importantly, when we wish <strong>to</strong> underst<strong>and</strong> the difficulty of aproblem, reduction allows us <strong>to</strong> make relative statements about upper <strong>and</strong> lowerbounds on the cost of a problem (as opposed <strong>to</strong> an algorithm or program).Because the concept of a problem is discussed extensively in this chapter, wewant notation <strong>to</strong> simplify problem descriptions. Throughout this chapter, a problemwill be defined in terms of a mapping between inputs <strong>and</strong> outputs, <strong>and</strong> the name ofthe problem will be given in all capital letters. Thus, a complete definition of thesorting problem could appear as follows:SORTING:Input: A sequence of integers x 0 , x 1 , x 2 , ..., x n−1 .Output: A permutation y 0 , y 1 , y 2 , ..., y n−1 of the sequence such that y i ≤ y jwhenever i < j.Once you have bought or written a program <strong>to</strong> solve one problem, such assorting, you might be able <strong>to</strong> use it as a <strong>to</strong>ol <strong>to</strong> solve a different problem. This is

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

Saved successfully!

Ooh no, something went wrong!