# chap8 - Chapter 8 NP-complete problems 8.1 Search problems...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Chapter 8 NP-complete problems 8.1 Search problems Over the past seven chapters we have developed algorithms for finding shortest paths and minimum spanning trees in graphs, matchings in bipartite graphs, maximum increasing sub- sequences, maximum flows in networks, and so on. All these algorithms are efficient , because in each case their time requirement grows as a polynomial function (such as n , n 2 , or n 3 ) of the size of the input. To better appreciate such efficient algorithms, consider the alternative: In all these prob- lems we are searching for a solution (path, tree, matching, etc.) from among an exponential population of possibilities. Indeed, n boys can be matched with n girls in n ! different ways, a graph with n vertices has n n- 2 spanning trees, and a typical graph has an exponential num- ber of paths from s to t . All these problems could in principle be solved in exponential time by checking through all candidate solutions, one by one. But an algorithm whose running time is 2 n , or worse, is all but useless in practice (see the next box). The quest for efficient algorithms is about finding clever ways to bypass this process of exhaustive search, using clues from the input in order to dramatically narrow down the search space. So far in this book we have seen the most brilliant successes of this quest, algorithmic tech- niques that defeat the specter of exponentiality: greedy algorithms, dynamic programming, linear programming (while divide-and-conquer typically yields faster algorithms for problems we can already solve in polynomial time). Now the time has come to meet the quest’s most embarrassing and persistent failures. We shall see some other “search problems,” in which again we are seeking a solution with particular properties among an exponential chaos of al- ternatives. But for these new problems no shortcut seems possible. The fastest algorithms we know for them are all exponential—not substantially better than an exhaustive search. We now introduce some important examples. 247 248 Algorithms The story of Sissa and Moore According to the legend, the game of chess was invented by the Brahmin Sissa to amuse and teach his king. Asked by the grateful monarch what he wanted in return, the wise man requested that the king place one grain of rice in the first square of the chessboard, two in the second, four in the third, and so on, doubling the amount of rice up to the 64th square. The king agreed on the spot, and as a result he was the first person to learn the valuable—-albeit humbling—lesson of exponential growth . Sissa’s request amounted to 2 64- 1 = 18 , 446 , 744 , 073 , 709 , 551 , 615 grains of rice, enough rice to pave all of India several times over!...
View Full Document

{[ snackBarMessage ]}

### Page1 / 36

chap8 - Chapter 8 NP-complete problems 8.1 Search problems...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online