© from notes written mostly by Dr. Matt Stallmann: All Rights Reserved CSC 505, Fall 2000: Week 10 Objectives: • understand problem complexity and classes defined by it • understand relationships among decision, witness, evaluation, and optimization problems • understand what it means to reduce one problem to another • understand the meaning of membership in the class NP, and NP-completeness
Page 1 of 21
© from notes written mostly by Dr. Matt Stallmann: All Rights Reserved A complexity class (a class of problems that are related based on the efficiency -- time or space -- of the best possible algorithms for them)
Class P is the class of all decision problems that can be solved in time polynomial in the input size. Questions:
1. Why polynomial? (i.e. why is P an important class?)
2. Why decision problems?
3. How do we count time and input size?
Page 2 of 21
© from notes written mostly by Dr. Matt Stallmann: All Rights Reserved MST as a decision problem/language MST decision problem: Given a weighted,undirected graph G = (V,E,w) and an integer k, does G have a spanning tree whose total weight is k?
LMST = { strings z | z encodes a graph G = (V,E,w) and an integer k and G has a spanning tree T with w(T) k }
1s @ 45 @ @ G = s @s 238 z = 1#10#100##1#11#101##10#11#1000###111 Do the details of the encoding matter?
Page 3 of 21
© from notes written mostly by Dr. Matt Stallmann: All Rights Reserved Rules for this particular encoding
alphabet = {0,1,#} xed, nite hinstancei ::= hgraphi###hinti G and k hgraphi ::= hedgei{##hedgei} list of edges hedgei ::= hvertexi#vertexi#hinti 2 ends and weight hvertexi ::= hinti vertex names are ints hinti ::= hbiti{hbiti} ints are in binary hbiti ::= 0 | 1
12s 8 s ¨ ¨¨ 659¨ ¨¨ Another example: G = s¨ s k =18 347 1#10#1000##1#11#110##11#10#1001##11#100#111##10#100#101###10010
Page 4 of 21
© from notes written mostly by Dr. Matt Stallmann: All Rights Reserved Types of combinatorial problems Optimization a combinatorial object (set, sequence, .. . ) of optimum (min/max) weight Example: Output a minimum spanning tree T of G = (V,E,w). Evaluation the weight of an optimum object Example: Output w(T ), the weight of a minimum spanning tree T of G = (V,E,w). Decision yes/no (does an object of a certain weight or better exist) Example: Given G = (V,E,w) and an integer k, does there exist a spanning tree T such that w(T) k? Witness a certi cate for the decision problem, i.e. proof of a yes answer if such proof exists Example: Given G = (V,E,w) and an integer k, output a spanning tree T with w(T) k or report that none exists.
Page 5 of 21
© from notes written mostly by Dr. Matt Stallmann: All Rights Reserved Are the problem types related?