40 likes | 113 Views
Dealing with “intractability” (con’t) (PS98, chapt. 16-18). PARTITION is NP-complete: Given integers c 1 ,c 2 ,…,c n is there a subset S such that Σ S c i = ½ Σ c i ? Known to be NP-complete. Here’s an algorithm: Let K = ½ Σ c i . Make an array 1… K.
E N D
Dealing with “intractability” (con’t) (PS98, chapt. 16-18) • PARTITION is NP-complete: Given integers c1,c2,…,cnis there a subset S such that ΣS ci = ½Σci ? Known to beNP-complete. Here’s an algorithm: Let K= ½Σci . Make an array 1…K. Mark location c1. Then location c2, c1+c2. … Then ciand x+ci for all previously marked locations x, all i. If K gets marked, YES, else NO.
Proof: induction, assume all possible sums are marked for i-1. Then true for i. • Complexity: Initialize: K. Then triangular sum = O(n2). Total complexity is O(K+n2), assuming constant-time for access. • Appears to be polynomial…? But PARTITION is NP-complete! Explain. • This can be a practical approach to some NP-complete problems---if the numbers involved are not too big.
Other approaches to “intractable” problems • Branch-and-bound • Ad-hoc approximation algorithms; sometimes quality is provable • Dynamic programming • “New-age” algorithms: simulated annealing, genetic algorithms, neural networks, etc.
Branch-and-Bound Reingold, Nievergelt, Deo 77