# Theoretical Computer Science (Bridging Course) Complexity

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 Theoretical Computer Science (Bridging Course) Complexity Gian Diego Tipaldi

2 A scenario You are a programmer working for a logistics company Your boss asks you to implement a program that optimizes the travel route of your company s delivery truck: The truck is initially located in your depot There are 50 locations the truck must visit on its route You know the travel distances between all locations (including the depot) Your job is to write a program that determines a route from the depot via all locations back to the depot that minimizes total travel distance 2

3 A scenario (ctd) You try solving the problem for weeks, but don t manage to come up with a program All your attempts either cannot guarantee optimality or don t terminate within reasonable time (say, a month of computation) What do you tell your boss? 3

4 Proof Idea I can t find an efficient algorithm, I guess I m just too dumb source: M Garey & D Johnson, Computers and Intractability, Freeman 1979, p 2 4

5 What you would ideally like to say I can t find an efficient algorithm, because no such algorithm is possible! source: M Garey & D Johnson, Computers and Intractability, Freeman 1979, p 2 4

6 What complexity theory allows you to say I can t find an efficient algorithm, but neither can all these famous people source: M Garey & D Johnson, Computers and Intractability, Freeman 1979, p 3 4

7 Why complexity theory? Complexity theory tells us which problems can be solved quickly ( easy problems ) and which ones cannot ( hard problems ) This is useful because different algorithmic techniques are required for problems for easy and hard problems Moreover, if we can prove a problem to be hard, we should not waste our time looking for easy algorithms 5

8 Why reductions? One important part of complexity theory are reductions that show how a new problem P can be expressed in terms of a known problem Q This is useful for theoretical analyses of P because it allows us to apply our knowledge about Q It is also often useful for practical algorithms because we can use the best known algorithm for Q and apply it to P 6

9 Complexity pop quiz The following slide contains a selection of graph problems In all cases, the input is a directed, weighted graph G = V, A, w with positive edge weights How hard do you think these graph problems are? Sort from easiest (least time to solve) to hardest (most time to solve) No justifications needed, just follow your intuition! 7

10 Some graph problems I 1 Find a cycle-free path from u V to v V with minimum cost 2 Find a cycle-free path from u V to v V with maximum cost 3 Determine if G is strongly connected (paths exist from everywhere to everywhere) 4 Determine if G is weakly connected (paths exist from everywhere to everywhere, ignoring arc directions) 8

11 Some graph problems II 5 Find a directed cycle 6 Find a directed cycle involving all vertices 7 Find a directed cycle involving a given vertex u 8 Find a path visiting all vertices without repeating a vertex 9 Find a path using all arcs without repeating an arc 9

12 Overview of this chapter Refresher: asymptotic growth ( big-o notation ) Models of computation P and NP Polynomial reductions NP-hardness and NP-completeness Some NP-complete problems 10

13 Asymptotic growth: motivation Often, we are interested in how an algorithm behaves on large inputs, as these tend to be most critical in practice For example, consider the following problem: Duplicate elimination Input: a sequence of words s 1,, s n over some alphabet Output: the same words, in any order, without duplicates 11

14 Asymptotic growth: motivation Here are three algorithms for the problem: 1 The naive algorithm with two nested for loops 2 Sort input; traverse sorted list and skip duplicates 3 Hash & report new entries upon insertion Which one is fastest? Let s compare! 12

15 Runtimes of the algorithms Assume that on an input with n words, the algorithms require (in µs): 1 f 1 (n) = 01n 2 2 f 2 (n) = 10n log n + 01n 3 f 3 (n) = 30n 13

16 Runtimes of the algorithms Assume that on an input with n words, the algorithms require (in µs): 1 f 1 (n) = 01n 2 2 f 2 (n) = 10n log n + 01n 3 f 3 (n) = 30n runtime 1000 s 100 s 10 s 1 s 100 ms 10 ms 1 ms 100 µs 10 µs A1 A2 A

17 Runtime growth in the limit For very small inputs, A1 is faster than A2, which is faster than A3 However, for very large inputs, the ordering is opposite Big-O notation captures this by considering how runtime grows in the limit of large input sizes It also ignores constant factors, since for large enough inputs, these do not matter compared to differences in growth rate 14

18 Big-O: Definition Definition (O(g)) Let g : N 0 R be a function mapping from the natural numbers to the real numbers O(g) is the set of all functions f : N 0 R such that for some c R + and M N 0, we have f(n) c g(n) for all n M In words: from a certain point onwards, f is bounded by g multiplied with some constant Intuition: If f O(g), then f does not grow faster than g (maybe apart from constant factors that we do not care about) 15

19 Big-O: Notational conventions Formally, O(g) is a set of functions, so to express that function f belongs to this class, we should write f O(g) However, it is much more common to write f = O(g) instead of f O(g) In this context, = is pronounced is, not equals : f is O of g For example, it is not symmetric: we write f = O(g), but not O(g) = f 16

20 Big-O: Notational conventions Further abbreviations: Notation like f = O(g) where g(n) = n 2 is often abbreviated to f = O(n 2 ) Similarly, if for example f(n) = n log n, we can further abbreviate this to n log n O(n 2 ) 17

21 Big-O example (1) Big-O example Let f(n) = 3n n + 7 We show that f = O(n 2 ) 18

22 Big-O example (2) Big-O example Let f(n) = 3n n + 7 We show that f = O(n 3 ) 19

23 Big-O example (3) Big-O example Let f(n) = n 100 We show that f = O(2 n ) (We may use that log 2 (x) x for all x 25) 20

24 Big-O for the duplicate elimination example In the duplicate elimination example, using big-o notation we can show that f 1 = O(n 2 ) f 2 = O(n log n) f 3 = O(n) Moreover, big-o notation allows us to order the runtimes: f 3 = O(f 1 ), but not f 1 = O(f 3 ) f 2 = O(f 1 ), but not f 1 = O(f 2 ) f 3 = O(f 2 ), but not f 2 = O(f 3 ) 21

25 What is runtime complexity? Runtime complexity is a measure that tells us how much time we need to solve a problem How do we define this appropriately? 22

26 Examples of different statements about runtime Running sort /usr/share/dict/words on computer alfons requires 0242 seconds On an input file of size 1 MB, sort requires at most 1 second on a modern computer Quicksort is faster than Insertion sort Insertion sort is slow These are very different statements, each with different advantages and disadvantages 23

27 Precise statements vs general statements Running sort /usr/share/dict/words on computer alfons requires 0242 seconds Advantage: very precise Disadvantage: not general input-specific: What if we want to sort other files? machine-specific: What if we run the program on another machine? even situation-specific: If we run the program again tomorrow, will we get the same result? 24

28 General statements about runtime In this course, we want to make general statements about runtime This is accomplished in three ways: 25

29 General statements about runtime In this course, we want to make general statements about runtime This is accomplished in three ways: 1 Rather than consider runtime for a particular input, we consider general classes of inputs: Example: worst-case runtime to sort any input of size n Example: average-case runtime to sort any input of size n 25

30 General statements about runtime In this course, we want to make general statements about runtime This is accomplished in three ways: 2 Rather than consider runtime on a particular machine, we consider more abstract cost measures: Example: count executed x86 machine code instructions Example: count executed Java bytecode instructions Example: for sort algorithms, count number of comparisons 25

31 General statements about runtime In this course, we want to make general statements about runtime This is accomplished in three ways: 3 Rather than consider all implementation details, we ignore unimportant aspects: Example: rather than saying that we need 4n 12 log n + 10 instructions, we say that we need a linear number (O(n)) of instructions 25

32 Which computational model do we use? We know many models of computation: Programs in some programming language For example Java, C++, Scheme, Turing machines Variants: single-tape or multi-tape Variants: deterministic or nondeterministic Push-down automata Finite automata Variants: deterministic or nondeterministic 26

33 Which computational model do we use? Here, we use Turing machines because they are the most powerful of our formal computation models (Programming languages are equally powerful, but not formal enough, and also too complicated) 27

34 Are Turing machines an adequate model? According to the Church-Turing thesis, everything that can be computed can be computed by a Turing machine However, many operations that are easy on an actual computer require a lot of time on a Turing machine Runtime on a Turing machine is not necessarily indicative of runtime on an actual machine! 28

35 Are Turing machines an adequate model? The main problem of Turing machines is that they do not allow random access Alternative formal models of computation exist: Examples: lambda calculus, register machines, random access machines (RAMs) Some of these are closer to how today s computers actually work (in particular, RAMs) 29

36 Turing machines are an adequate enough model So Turing machines are not the most accurate model for an actual computer However, everything that can be done in a more realistic model in n computation steps can be done on a TM with at most polynomial overhead (e g, in n 2 steps) For the big topic of this part of the course, the P vs NP question, we do not care about polynomial overhead 30

37 Turing machines are an adequate enough model Hence, for this purpose TMs are an adequate model, and they have the advantage of being easy to analyze Hence, we use TMs in the following For more fine-grained questions (e g, linear vs quadratic algorithms), one should use a different computation model 31

38 Which flavour of Turing machines do we use? There are many variants of Turing machines: deterministic or nondeterministic one tape or multiple tapes one-way or two-way infinite tapes tape alphabet size: 2, 3, 4, Which one do we use? 32

39 Deterministic or nondeterministic Turing machines? We earlier proved that deterministic TMs (DTMs) and nondeterministic ones (NTMs) have the same power However, there we did not care about speed The DTM simulation of an NTM we presented can cause an exponential slowdown Are NTMs more powerful than DTMs if we care about speed, but don t care about polynomial overhead? 33

40 Deterministic or nondeterministic Turing machines? Are NTMs more powerful than DTMs if we care about speed, but don t care about polynomial overhead? Actually, that is the big question: it is one of the most famous open problems in mathematics and computer science To get to the core of this question, we will consider both kinds of TM separately 34

41 What about the other variations? Multi-tape TMs can be simulated on single-tape TMs with quadratic overhead TMs with two-way infinite tapes can be simulated on TMs with one-way infinite tapes with constant-factor overhead, and vice versa TMs with tape alphabets of any size K can be simulated on TMs with tape alphabet {0, 1, } with constant-factor overhead log 2 K 35

42 Nondeterministic Turing machines Definition A nondeterministic Turing machine (NTM) is a 6-tuple Σ,, Q, q 0, q acc, δ, where Σ is the finite, non-empty input alphabet / Σ is the blank symbol Q is the finite set of states q 0 Q is the initial state, q acc Q the accepting state δ (Q Σ ) (Q Σ { 1, +1}) is the transition relation 36

43 Deterministic Turing machines Definition An NTM Σ,, Q, q 0, q acc, δ is called deterministic (a DTM) if for all q Q, a Σ there is exactly one triple q, a, with q, a, q, a, δ We then denote this triple with δ(q, a) Note: In this definition, a DTM is a special case of an NTM, so if we define something for all NTMs, it is automatically defined for DTMs 37

44 Turing machine configurations Definition (configuration) Let M = Σ,, Q, q 0, q acc, δ be an NTM A configuration of M is a triple w, q, x Σ Q Σ+ w: tape contents before tape head q: current state x: tape contents after and including tape head 38

45 Turing machine transitions Definition (yields relation) Let M = Σ,, Q, q 0, q acc, δ be an NTM A configuration c of M yields a configuration c of M, in symbols c c, as defined by the following rules, where a, a, b Σ, w, x Σ, q, q Q and q, a, q, a, δ: w, q, ax wa, q, x if = +1, x 1 w, q, a wa, q, if = +1 wb, q, ax w, q, ba x if = 1 ϵ, q, ax ϵ, q, a x if = 1 39

46 Acceptance of configurations Definition (Acceptance within time n) Let c be a configuration of an NTM M Acceptance within time n is inductively defined as follows: If c = w, q acc, x where q acc is the accepting state of M, then M accepts c within time n for all n N 0 If c c and M accepts c within time n 1, then M accepts c within time n 40

47 Acceptance of words Definition (Acceptance within time n) Let M = Σ,, Q, q 0, q acc, δ be an NTM M accepts the word w Σ within time n N 0 iff M accepts ϵ, q 0, w within time n Special case: M accepts ϵ within time n N 0 iff M accepts ϵ, q 0, within time n 41

48 Acceptance of languages Definition (Acceptance within time f) Let M be an NTM with input alphabet Σ Let f : N 0 N 0 M accepts the language L Σ within time f iff M accepts each word w L within time at most f( w ), and M does not accept any word w / L 42

49 P and NP Definition (P and NP) P is the set of all languages L for which there exists a DTM M and a polynomial p such that M accepts L within time p NP is the set of all languages L for which there exists an NTM M and a polynomial p such that M accepts L within time p 43

50 P and NP Sets of languages like P and NP that are defined in terms of resource bounds for TMs are called complexity classes We know that P NP (Why?) Whether the converse holds is an open problem: this is the famous P vs NP question 44

51 General algorithmic problems vs decision problems An important aspect of complexity theory is to compare the difficulty of solving different algorithmic problems Examples: sorting, finding shortest paths, finding cycles in graphs including all vertices, Solutions to algorithmic problems take different forms Examples: a sorted sequence, a path, a cycle, 45

52 General algorithmic problems vs decision problems To simplify the study, complexity theory limits attention to decision problems, i e, where the solution is Yes or No Is this sequence sorted? Is there a path from u to v of cost at most K? Is there a cycle in this graph that includes all vertices? We can usually show that if the decision problem is easy, then the corresponding algorithmic problem is also easy 46

53 Decision problems: example Using decision problems to solve more general problems [O] Shortest path optimization problem: Input: Directed, weighted graph G = V, A, w with positive edge weights w : A N 1, vertices u V, v V Output: A shortest (= minimum-cost) path from u to v 47

54 Decision problems: example Using decision problems to solve more general problems [D] Shortest path decision problem: Input: Directed, weighted graph G = V, A, w with positive edge weights w : A N 1, vertices u V, v V, cost bound K N 0 Question: Is there a path from u to v with cost K? 48

55 Decision problems: example Using decision problems to solve more general problems If we can solve [O] in polynomial time, we can solve [D] in polynomial time and vice versa 49

56 Decision problems as languages Decision problems can be represented as languages: For every decision problem we must express the input as a word over some alphabet Σ The language defined by the decision problem then contains a word w Σ iff w is a well-formed input for the decision problem the correct answer for input w is Yes 50

57 Decision problems as languages Example (shortest path decision problem): w SP iff the input properly describes G, u, v, K such that G is a graph, arc weights are positive, etc that graph G has a path of cost at most K from u to v 51

58 Decision problems as languages Since decision problems can be represented as languages, we do not distinguish between languages and (decision) problems from now on For example, we can say that P is the set of all decision problems that can be solved in polynomial time by a DTM Similarly, NP is the set of all decision problems that can be solved in polynomial time by an NTM 52

59 Decision problems as languages From the definition of NTM acceptance, solved means If w is a Yes instance, then the NTM has some polynomial-time accepting computation for w If w is a No instance (or not a well-formed input), then the NTM never accepts it 53

60 Example: HamiltonianCycle NP The HamiltonianCycle problem is defined as follows: Given: An undirected graph G = V, E Question: Does G contain a Hamiltonian cycle? 54

61 Example: HamiltonianCycle NP A Hamiltonian cycle is a path π = v 0, v 1,, v n such that π is a path: for all i {0,, n 1}, {v i, v i+1 } E π is a cycle: v 0 = v n π is simple: v i v j for all i, j {1,, n} with i j π is Hamiltonian: for all v V, there exists i {1,, n} such that v = v i We show that HamiltonianCycle NP 55

62 Guess and check The (nondeterministic) Hamiltonian Cycle algorithm illustrates a general design principle for NTMs: guess and check NTMs can solve decision problems in polynomial time by nondeterministically guessing a solution (also called witness or proof ) for the instance deterministically verifying that the guessed witness indeed describes a proper solution, and accepting iff it does It is possible to prove that all decision problems in NP can be solved by an NTM using such a guess-and-check approach 56

63 Polynomial reductions: idea Reductions are a very common and powerful idea in mathematics and computer science The idea is to solve a new problem by reducing (mapping) it to one for which we already know how to solve it Polynomial reductions (also called Karp reductions) are an example of this in the context of decision problems 57

64 Polynomial reductions Definition (Polynomial reductions) Let A Σ and B Σ be decision problems for alphabet Σ We say that A is polynomially reducible to B, written A p B, if there exists a DTM M with the following properties: M is polynomial-time i e, there is a polynomial p such that M stops within time p( w ) on any input w Σ 58

65 Polynomial reductions Definition (Polynomial reductions) Let A Σ and B Σ be decision problems for alphabet Σ We say that A is polynomially reducible to B, written A p B, if there exists a DTM M with the following properties: M reduces A to B i e, for all w Σ : (w A iff f M (w) B), where f M (w) is the tape content of M after stopping, ignoring blanks 58

66 Polynomial reduction: example HamiltonianCycle p TSP The TSP (Travelling Salesperson) problem is defined as follows: Given: A finite nonempty set of locations L, a symmetric travel cost function cost : L L N 0, a cost bound K N 0 Question: Is there a tour of total cost at most K, i e, a permutation l 1,, l n of the locations such that n 1 i=1 cost(l i, l i+1 ) + cost(l n, l 1 ) K? We show that HamiltonianCycle p TSP 59

67 Polynomial reduction: properties Theorem (properties of polynomial reductions) Let A, B, C be decision problems over alphabet Σ 1 If A p B and B P, then A P 2 If A p B and B NP, then A NP 3 If A p B and A / P, then B / P 4 If A p B and A / NP, then B / NP 5 If A p B and B p C, then A p C 60

68 NP-hardness & NP-completeness Definition (NP-hard, NP-complete) Let B be a decision problem B is called NP-hard if A p B for all problems A NP B is called NP-complete if B NP and B is NP-hard 61

69 NP-hardness & NP-completeness NP-hard problems are at least as hard as all problems in NP NP-complete problems are the hardest problems in NP Do NP-complete problems exist? If A P for any NP-complete problem A, then P = NP Why? 62

70 SAT is NP-complete Definition (SAT) The SAT (satisfiability) problem is defined as follows: Given: A propositional logic formula φ Question: Is φ satisfiable? 63

71 SAT is NP-complete Definition (SAT) The SAT (satisfiability) problem is defined as follows: Given: A propositional logic formula φ Question: Is φ satisfiable? Theorem (Cook, 1971) ṢAT is NP-complete 63

72 NP-hardness proof for SAT Proof SAT NP: Guess and check SAT is NP-hard: This is more involved 64

73 NP-hardness proof for SAT Proof SAT NP: Guess and check SAT is NP-hard: This is more involved We must show that A p SAT for all A NP 64

74 NP-hardness proof for SAT Proof SAT NP: Guess and check SAT is NP-hard: This is more involved We must show that A p SAT for all A NP Let A NP This means that there exists a polynomial p and an NTM M st M accepts A within time p Let w Σ be the input for A 64

75 NP-hardness proof for SAT Proof (ctd) We must, in polynomial time, construct a propositional logic formula f(w) st w A iff f(w) SAT (i e, is satisfiable) 65

76 NP-hardness proof for SAT Proof (ctd) We must, in polynomial time, construct a propositional logic formula f(w) st w A iff f(w) SAT (i e, is satisfiable) Idea: Construct a logical formula that encodes the possible configurations that M can reach from input w and which is satisfiable iff an accepting configuration is reached 65

77 NP-hardness proof for SAT (ctd) Proof (ctd) Let M = Σ,, Q, q 0, q acc, δ be the NTM for A We assume (wlog) that it never moves to the left of the initial position Let w = w 1 w n Σ be the input for M Let p be the run-time bounding polynomial for M Let N = p(n) + 1 (wlog N n) 66

78 NP-hardness proof for SAT (ctd) Proof (ctd) During any computation that takes time p(n), M can only visit the first N tape cells We can encode any configuration of M that can possibly be part of an accepting configuration by denoting: what the current state of M is which of the tape cells {1,, N} is the current location of the tape head which of the symbols in Σ is contained in each of the tape cells {1,, N} 67

79 NP-hardness proof for SAT (ctd) Proof (ctd) Use these propositional variables in f(w): state t,q (t {0,, N}, q Q) encode Turing Machine state in t-th configuration head t,i (t {0,, N}, i {1,, N}) encode tape head location in t-th configuration content t,i,a (t {0,, N}, i {1,, N}, a Σ ) encode tape contents in t-th configuration 68

80 NP-hardness proof for SAT (ctd) Proof (ctd) Construct f(w) in such a way that every satisfying assignment describes a sequence of configurations of the TM that starts from the initial configuration and reaches an accepting configuration and follows the transition rules in δ 69

81 NP-hardness proof for SAT (ctd) Proof (ctd) y X\{x} (x y)) oneof X := ( x X x) ( x X 1 Describe a sequence of configurations of the TM: N Valid := (oneof {state t,q q Q} t=0 oneof {head t,i i {1,, N}} N oneof {content t,i,a a Σ }) i=1 70

82 NP-hardness proof for SAT (ctd) Proof (ctd) 2 Start from the initial configuration: Init := state 0,q0 head 0,1 n N content 0,i,wi content 0,i, i=1 i=n+1 71

83 NP-hardness proof for SAT (ctd) Proof (ctd) 3 Reach an accepting configuration: Accept := N t=0 state t,qacc 72

84 NP-hardness proof for SAT (ctd) Proof (ctd) 4 Follow the transition rules in δ: Trans := where ((state t,qacc Noop t ) N 1 t=0 ( state t,qacc R δ N Rule t,i,r )) i=1 73

85 NP-hardness proof for SAT (ctd) Proof (ctd) 4 Follow the transition rules in δ (ctd): Noop t := q Q(state t,q state t+1,q ) N (head t,i head t+1,i ) i=1 N i=1 a Σ (content t,i,a content t+1,i,a ) 74

86 NP-hardness proof for SAT (ctd) Proof (ctd) 4 Follow the transition rules in δ (ctd): Rule t,i, q,a, q,a, := (state t,q state t+1,q ) (head t,i head t+1,i+ ) (content t,i,a content t+1,i,a ) j {1,,N}\{i} a Σ (content t,j,a content t+1,j,a ) 75

87 NP-hardness proof for SAT (ctd) Proof (ctd) Define f(w) := Valid Init Accept Trans f(w) can be computed in poly time in w w A iff M accepts w within time p( w ) w A iff f(w) is satisfiable w A iff f(w) SAT A p SAT Since A NP was chosen arbitrarily, we can conclude that SAT is NP-hard and hence NP-complete 76

88 More NP-complete problems The proof of NP-hardness of SAT was rather involved However, we can now prove that other problems are NP-hard much easily Simply prove A p B for some known NP-hard problem A (eg,sat) This proves that B is NP-hard Why? Garey & Johnson s textbook Computers and Intractability A Guide to the Theory of NP-Completeness (1979) lists several hundred NP-complete problems 77

89 3SAT is NP-complete Definition (3SAT) The 3SAT problem is defined as follows: Given: A propositional logic formula φ in CNF with at most three literals per clause Question: Is φ satisfiable? 78

90 3SAT is NP-complete Definition (3SAT) The 3SAT problem is defined as follows: Given: A propositional logic formula φ in CNF with at most three literals per clause Question: Is φ satisfiable? Theorem 3SAT is NP-complete 78

91 3SAT is NP-complete Theorem 3SAT is NP-complete 79

92 3SAT is NP-complete Theorem 3SAT is NP-complete Proof 3SAT NP: Guess and check 3SAT is NP-hard: SAT p 3SAT 79

93 Clique is NP-complete Definition (Clique) The Clique problem is defined as follows: Given: An undirected graph G = V, E and a number K N 0 Question: Does G contain a clique of size at least K, i e, a vertex set C V with C K such that u, v E for all u, v C with u v? 80

94 Clique is NP-complete Definition (Clique) The Clique problem is defined as follows: Given: An undirected graph G = V, E and a number K N 0 Question: Does G contain a clique of size at least K, i e, a vertex set C V with C K such that u, v E for all u, v C with u v? Theorem Clique is NP-complete 80

95 Clique is NP-complete Theorem Clique is NP-complete 81

96 Clique is NP-complete Theorem Clique is NP-complete Proof Clique NP: Guess and check Clique is NP-hard: 3SAT p Clique 81

97 IndSet is NP-complete Definition (IndSet) The IndSet problem is defined as follows: Given: An undirected graph G = V, E and a number K N 0 Question: Does G contain an independent set of size at least K, i e, a vertex set I V with I K such that for all u, v I, u, v / E? 82

98 IndSet is NP-complete Definition (IndSet) The IndSet problem is defined as follows: Given: An undirected graph G = V, E and a number K N 0 Question: Does G contain an independent set of size at least K, i e, a vertex set I V with I K such that for all u, v I, u, v / E? Theorem ỊndSet is NP-complete 82

99 IndSet is NP-complete Theorem ỊndSet is NP-complete 83

100 IndSet is NP-complete Theorem ỊndSet is NP-complete Proof IndSet NP: Guess and check IndSet is NP-hard: Clique p IndSet (exercises) Idea: Map to complement graph 83

101 VertexCover is NP-complete Definition (VertexCover) The VertexCover problem is defined as follows: Given: An undirected graph G = V, E and a number K N 0 Question: Does G contain an vertex cover of size at most K, i e, a vertex set C V with C K s t for all u, v E, we have u C or v C? 84

102 VertexCover is NP-complete Theorem ṾertexCover is NP-complete 85

103 VertexCover is NP-complete Theorem ṾertexCover is NP-complete Proof VertexCover NP: Guess and check VertexCover is NP-hard: IndSet p VertexCover (exercises) Idea: C is a vertex cover iff V \ C is an independent set 85

104 DirHamiltonianCycle is NPcomplete Definition (DirHamiltonianCycle) The DirHamiltonianCycle problem is defined as follows: Given: A directed graph G = V, A Question: Does G contain a directed Hamiltonian cycle (i e, a cyclic path visiting each vertex exactly once)? 86

105 DirHamiltonianCycle is NPcomplete Definition (DirHamiltonianCycle) The DirHamiltonianCycle problem is defined as follows: Given: A directed graph G = V, A Question: Does G contain a directed Hamiltonian cycle (i e, a cyclic path visiting each vertex exactly once)? Theorem ḌirHamiltonianCycle is NP-complete 86

106 DirHamiltonianCycle is NPcomplete Theorem ḌirHamiltonianCycle is NP-complete 87

107 DirHamiltonianCycle is NPcomplete Theorem ḌirHamiltonianCycle is NP-complete Proof sketch DirHamiltonianCycle NP: Guess and check DirHamiltonianCycle is NP-hard: 3SAT p DirHamiltonianCycle 87

108 DirHamiltonianCycle is NPcomplete (ctd) Proof sketch (ctd) A 3SAT instance φ is given Wlog each clause has exactly three literals, wuthout repetitions within a clause Let v 1,, v n be the propositional variables Let c 1,, c m be the clauses of φ, where each c i is of the form l i1 l i2 l i3 The reduction generates a graph f(φ) with 6m + n vertices, described in the following 88

109 DirHamiltonianCycle is NPcomplete (ctd) Proof sketch (ctd) Introduce vertex x i with indegree 2 and outdegree 2 for each variable v i : x 1 x 2 x n Introduce subgraph C j with six vertices for each clause c j : ȧ A b c B C 89

110 DirHamiltonianCycle is NPcomplete (ctd) Proof sketch (ctd) Let π be a directed Hamiltonian cycle of the overall graph Whenever π traverses C j, it must leave it at the corresponding exit for the given entrance (i e, a A, b B, c C) Otherwise π cannot be a Hamiltonian cycle 90

111 DirHamiltonianCycle is NPcomplete (ctd) Proof sketch (ctd) The following are all valid possibilities for Hamiltonian cycles in graphs containing C j : π crosses C j once, entering at any entrance π crosses C j twice, entering at any two different entrances π crosses C j three times, entering once at each entrance 91

112 DirHamiltonianCycle is NPcomplete (ctd) Proof sketch (ctd) Connect the open ends of the graph as follows: Identify the entrances and exits of the C j graphs with the three literals of clause c j One exit of x i is positive, one negative Connect the positive and negative exits with the corresponding variables in the clauses 92

113 DirHamiltonianCycle is NPcomplete (ctd) Proof sketch (ctd) For the positive exit, determine the clauses in which the positive literal v i occurs Connect the positive x i exit to the v i entrance of the C j graph for the first such clause Connect the v i exit of that graph to the x i entrance of the second such clause, and so on Connect the v i exit of the last such clause to the positive entrance of x i+1 (or x 1 if n = 1) Similarly for the negative exit of x i and literal v i 93

114 DirHamiltonianCycle is NPcomplete (ctd) Proof sketch (ctd) This is a polynomial reduction ( ): Given a satisfying truth assignment α(v i ), we can construct a Hamiltonian cycle by leaving x i through the positive exit if α(v i ) = T; the negative exit if α(v i ) = F We can then visit all C j graphs for clauses made true by that literal Overall, we visit each C j graph 1 3 times 94

115 DirHamiltonianCycle is NPcomplete (ctd) Proof sketch (ctd) This is a polynomial reduction ( ): A Hamiltonian cycle visits each vertex x i and leaves it through the positive or negative exit Set v i to true or false according to which exit is chosen This gives a satisfying truth assignment 95

116 HamiltonianCycle is NP-complete Theorem ḤamiltonianCycle is NP-complete 96

117 HamiltonianCycle is NP-complete Theorem ḤamiltonianCycle is NP-complete Proof sketch HamiltonianCycle NP : Guess and check HamiltonianCycle is NP-hard: DirHamiltonianCycle p HamiltonianCycle Basic gadget of the reduction: v v 1 v 2 v 3 96

118 TSP is NP-complete Theorem ṬSP is NP-complete 97

119 TSP is NP-complete Theorem ṬSP is NP-complete Proof TSP NP : Guess and check TSP is NP-hard: HamiltonianCycle p TSP was already shown earlier 97

120 And many, many more SubsetSum: Given a 1,, a n N and K, is there a subsequence with sum exactly K? BinPacking: Given objects of size a 1,, a n, can they fit into K bins with capacity B? MineSweeperConsistency: In a given Minesweeper position, is a given cell safe? GeneralizedFreeCell: Does a generalized FreeCell deal (i e, one that may have more than 52 cards) have a solution? 98

121 Summary Complexity theory is about proving which problems are easy or hard Two important classes: P and NP We know P NP, but we do not know whether P = NP Many practically relevant problems are NP-complete, i e, as hard as any other problem in NP If there exists an efficient algorithm for one NP-complete problem, then there exists an efficient algorithm for all problems in NP 99

### Page 1. CSCE 310J Data Structures & Algorithms. CSCE 310J Data Structures & Algorithms. P, NP, and NP-Complete. Polynomial-Time Algorithms

CSCE 310J Data Structures & Algorithms P, NP, and NP-Complete Dr. Steve Goddard goddard@cse.unl.edu CSCE 310J Data Structures & Algorithms Giving credit where credit is due:» Most of the lecture notes

### Introduction to Logic in Computer Science: Autumn 2006

Introduction to Logic in Computer Science: Autumn 2006 Ulle Endriss Institute for Logic, Language and Computation University of Amsterdam Ulle Endriss 1 Plan for Today Now that we have a basic understanding

### NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

NP-Completeness CptS 223 Advanced Data Structures Larry Holder School of Electrical Engineering and Computer Science Washington State University 1 Hard Graph Problems Hard means no known solutions with

### Lecture 7: NP-Complete Problems

IAS/PCMI Summer Session 2000 Clay Mathematics Undergraduate Program Basic Course on Computational Complexity Lecture 7: NP-Complete Problems David Mix Barrington and Alexis Maciel July 25, 2000 1. Circuit

### 1. Nondeterministically guess a solution (called a certificate) 2. Check whether the solution solves the problem (called verification)

Some N P problems Computer scientists have studied many N P problems, that is, problems that can be solved nondeterministically in polynomial time. Traditionally complexity question are studied as languages:

### Tutorial 8. NP-Complete Problems

Tutorial 8 NP-Complete Problems Decision Problem Statement of a decision problem Part 1: instance description defining the input Part 2: question stating the actual yesor-no question A decision problem

### Why? A central concept in Computer Science. Algorithms are ubiquitous.

Analysis of Algorithms: A Brief Introduction Why? A central concept in Computer Science. Algorithms are ubiquitous. Using the Internet (sending email, transferring files, use of search engines, online

### NP-complete? NP-hard? Some Foundations of Complexity. Prof. Sven Hartmann Clausthal University of Technology Department of Informatics

NP-complete? NP-hard? Some Foundations of Complexity Prof. Sven Hartmann Clausthal University of Technology Department of Informatics Tractability of Problems Some problems are undecidable: no computer

### The Classes P and NP

The Classes P and NP We now shift gears slightly and restrict our attention to the examination of two families of problems which are very important to computer scientists. These families constitute the

### OHJ-2306 Introduction to Theoretical Computer Science, Fall 2012 8.11.2012

276 The P vs. NP problem is a major unsolved problem in computer science It is one of the seven Millennium Prize Problems selected by the Clay Mathematics Institute to carry a \$ 1,000,000 prize for the

### CSC 373: Algorithm Design and Analysis Lecture 16

CSC 373: Algorithm Design and Analysis Lecture 16 Allan Borodin February 25, 2013 Some materials are from Stephen Cook s IIT talk and Keven Wayne s slides. 1 / 17 Announcements and Outline Announcements

### Welcome to... Problem Analysis and Complexity Theory 716.054, 3 VU

Welcome to... Problem Analysis and Complexity Theory 716.054, 3 VU Birgit Vogtenhuber Institute for Software Technology email: bvogt@ist.tugraz.at office hour: Tuesday 10:30 11:30 slides: http://www.ist.tugraz.at/pact.html

### NP-Completeness and Cook s Theorem

NP-Completeness and Cook s Theorem Lecture notes for COM3412 Logic and Computation 15th January 2002 1 NP decision problems The decision problem D L for a formal language L Σ is the computational task:

### P versus NP, and More

1 P versus NP, and More Great Ideas in Theoretical Computer Science Saarland University, Summer 2014 If you have tried to solve a crossword puzzle, you know that it is much harder to solve it than to verify

### Complexity Theory. IE 661: Scheduling Theory Fall 2003 Satyaki Ghosh Dastidar

Complexity Theory IE 661: Scheduling Theory Fall 2003 Satyaki Ghosh Dastidar Outline Goals Computation of Problems Concepts and Definitions Complexity Classes and Problems Polynomial Time Reductions Examples

### Computer Algorithms. NP-Complete Problems. CISC 4080 Yanjun Li

Computer Algorithms NP-Complete Problems NP-completeness The quest for efficient algorithms is about finding clever ways to bypass the process of exhaustive search, using clues from the input in order

### On the Relationship between Classes P and NP

Journal of Computer Science 8 (7): 1036-1040, 2012 ISSN 1549-3636 2012 Science Publications On the Relationship between Classes P and NP Anatoly D. Plotnikov Department of Computer Systems and Networks,

### Complexity Classes P and NP

Complexity Classes P and NP MATH 3220 Supplemental Presentation by John Aleshunas The cure for boredom is curiosity. There is no cure for curiosity Dorothy Parker Computational Complexity Theory In computer

### Introduction to computer science

Introduction to computer science Michael A. Nielsen University of Queensland Goals: 1. Introduce the notion of the computational complexity of a problem, and define the major computational complexity classes.

### Diagonalization. Ahto Buldas. Lecture 3 of Complexity Theory October 8, 2009. Slides based on S.Aurora, B.Barak. Complexity Theory: A Modern Approach.

Diagonalization Slides based on S.Aurora, B.Barak. Complexity Theory: A Modern Approach. Ahto Buldas Ahto.Buldas@ut.ee Background One basic goal in complexity theory is to separate interesting complexity

### Chapter. NP-Completeness. Contents

Chapter 13 NP-Completeness Contents 13.1 P and NP......................... 593 13.1.1 Defining the Complexity Classes P and NP...594 13.1.2 Some Interesting Problems in NP.......... 597 13.2 NP-Completeness....................

### Notes on NP Completeness

Notes on NP Completeness Rich Schwartz November 10, 2013 1 Overview Here are some notes which I wrote to try to understand what NP completeness means. Most of these notes are taken from Appendix B in Douglas

### Computational complexity theory

Computational complexity theory Goal: A general theory of the resources needed to solve computational problems What types of resources? Time What types of computational problems? decision problem Decision

### Introduction to Algorithms. Part 3: P, NP Hard Problems

Introduction to Algorithms Part 3: P, NP Hard Problems 1) Polynomial Time: P and NP 2) NP-Completeness 3) Dealing with Hard Problems 4) Lower Bounds 5) Books c Wayne Goddard, Clemson University, 2004 Chapter

### Outline. NP-completeness. When is a problem easy? When is a problem hard? Today. Euler Circuits

Outline NP-completeness Examples of Easy vs. Hard problems Euler circuit vs. Hamiltonian circuit Shortest Path vs. Longest Path 2-pairs sum vs. general Subset Sum Reducing one problem to another Clique

### SIMS 255 Foundations of Software Design. Complexity and NP-completeness

SIMS 255 Foundations of Software Design Complexity and NP-completeness Matt Welsh November 29, 2001 mdw@cs.berkeley.edu 1 Outline Complexity of algorithms Space and time complexity ``Big O'' notation Complexity

### NP-Completeness I. Lecture 19. 19.1 Overview. 19.2 Introduction: Reduction and Expressiveness

Lecture 19 NP-Completeness I 19.1 Overview In the past few lectures we have looked at increasingly more expressive problems that we were able to solve using efficient algorithms. In this lecture we introduce

### Quantum and Non-deterministic computers facing NP-completeness

Quantum and Non-deterministic computers facing NP-completeness Thibaut University of Vienna Dept. of Business Administration Austria Vienna January 29th, 2013 Some pictures come from Wikipedia Introduction

### Chapter 1. NP Completeness I. 1.1. Introduction. By Sariel Har-Peled, December 30, 2014 1 Version: 1.05

Chapter 1 NP Completeness I By Sariel Har-Peled, December 30, 2014 1 Version: 1.05 "Then you must begin a reading program immediately so that you man understand the crises of our age," Ignatius said solemnly.

### A Working Knowledge of Computational Complexity for an Optimizer

A Working Knowledge of Computational Complexity for an Optimizer ORF 363/COS 323 Instructor: Amir Ali Ahmadi TAs: Y. Chen, G. Hall, J. Ye Fall 2014 1 Why computational complexity? What is computational

### Introduction to NP-Completeness Written and copyright c by Jie Wang 1

91.502 Foundations of Comuter Science 1 Introduction to Written and coyright c by Jie Wang 1 We use time-bounded (deterministic and nondeterministic) Turing machines to study comutational comlexity of

### 2.3 Scheduling jobs on identical parallel machines

2.3 Scheduling jobs on identical parallel machines There are jobs to be processed, and there are identical machines (running in parallel) to which each job may be assigned Each job = 1,,, must be processed

### Cloud Computing is NP-Complete

Working Paper, February 2, 20 Joe Weinman Permalink: http://www.joeweinman.com/resources/joe_weinman_cloud_computing_is_np-complete.pdf Abstract Cloud computing is a rapidly emerging paradigm for computing,

### Cost Model: Work, Span and Parallelism. 1 The RAM model for sequential computation:

CSE341T 08/31/2015 Lecture 3 Cost Model: Work, Span and Parallelism In this lecture, we will look at how one analyze a parallel program written using Cilk Plus. When we analyze the cost of an algorithm

### Reductions & NP-completeness as part of Foundations of Computer Science undergraduate course

Reductions & NP-completeness as part of Foundations of Computer Science undergraduate course Alex Angelopoulos, NTUA January 22, 2015 Outline Alex Angelopoulos (NTUA) FoCS: Reductions & NP-completeness-

### Notes on Complexity Theory Last updated: August, 2011. Lecture 1

Notes on Complexity Theory Last updated: August, 2011 Jonathan Katz Lecture 1 1 Turing Machines I assume that most students have encountered Turing machines before. (Students who have not may want to look

### Boulder Dash is NP hard

Boulder Dash is NP hard Marzio De Biasi marziodebiasi [at] gmail [dot] com December 2011 Version 0.01:... now the difficult part: is it NP? Abstract Boulder Dash is a videogame created by Peter Liepa and

### Theory of Computation Prof. Kamala Krithivasan Department of Computer Science and Engineering Indian Institute of Technology, Madras

Theory of Computation Prof. Kamala Krithivasan Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture No. # 31 Recursive Sets, Recursively Innumerable Sets, Encoding

Approximation Algorithms Chapter Approximation Algorithms Q. Suppose I need to solve an NP-hard problem. What should I do? A. Theory says you're unlikely to find a poly-time algorithm. Must sacrifice one

### ! X is a set of strings. ! Instance: string s. ! Algorithm A solves problem X: A(s) = yes iff s! X.

Decision Problems 8.2 Definition of NP Decision problem. X is a set of strings. Instance: string s. Algorithm A solves problem X: A(s) = yes iff s X. Polynomial time. Algorithm A runs in polytime if for

### Tetris is Hard: An Introduction to P vs NP

Tetris is Hard: An Introduction to P vs NP Based on Tetris is Hard, Even to Approximate in COCOON 2003 by Erik D. Demaine (MIT) Susan Hohenberger (JHU) David Liben-Nowell (Carleton) What s Your Problem?

### Exponential time algorithms for graph coloring

Exponential time algorithms for graph coloring Uriel Feige Lecture notes, March 14, 2011 1 Introduction Let [n] denote the set {1,..., k}. A k-labeling of vertices of a graph G(V, E) is a function V [k].

### Outline. Database Theory. Perfect Query Optimization. Turing Machines. Question. Definition VU , SS Trakhtenbrot s Theorem

Database Theory Database Theory Outline Database Theory VU 181.140, SS 2016 4. Trakhtenbrot s Theorem Reinhard Pichler Institut für Informationssysteme Arbeitsbereich DBAI Technische Universität Wien 4.

### Notes on Complexity Theory Last updated: August, 2011. Lecture 1

Notes on Complexity Theory Last updated: August, 2011 Jonathan Katz Lecture 1 1 Turing Machines I assume that most students have encountered Turing machines before. (Students who have not may want to look

### JUST-IN-TIME SCHEDULING WITH PERIODIC TIME SLOTS. Received December May 12, 2003; revised February 5, 2004

Scientiae Mathematicae Japonicae Online, Vol. 10, (2004), 431 437 431 JUST-IN-TIME SCHEDULING WITH PERIODIC TIME SLOTS Ondřej Čepeka and Shao Chin Sung b Received December May 12, 2003; revised February

### The P versus NP Solution

The P versus NP Solution Frank Vega To cite this version: Frank Vega. The P versus NP Solution. 2015. HAL Id: hal-01143424 https://hal.archives-ouvertes.fr/hal-01143424 Submitted on 17 Apr

### Introduction to Algorithms Review information for Prelim 1 CS 4820, Spring 2010 Distributed Wednesday, February 24

Introduction to Algorithms Review information for Prelim 1 CS 4820, Spring 2010 Distributed Wednesday, February 24 The final exam will cover seven topics. 1. greedy algorithms 2. divide-and-conquer algorithms

### Turing Machines: An Introduction

CIT 596 Theory of Computation 1 We have seen several abstract models of computing devices: Deterministic Finite Automata, Nondeterministic Finite Automata, Nondeterministic Finite Automata with ɛ-transitions,

### ! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. !-approximation algorithm.

Approximation Algorithms Chapter Approximation Algorithms Q Suppose I need to solve an NP-hard problem What should I do? A Theory says you're unlikely to find a poly-time algorithm Must sacrifice one of

### MATHEMATICS: CONCEPTS, AND FOUNDATIONS Vol. III - Logic and Computer Science - Phokion G. Kolaitis

LOGIC AND COMPUTER SCIENCE Phokion G. Kolaitis Computer Science Department, University of California, Santa Cruz, CA 95064, USA Keywords: algorithm, Armstrong s axioms, complete problem, complexity class,

### Lecture 2: Universality

CS 710: Complexity Theory 1/21/2010 Lecture 2: Universality Instructor: Dieter van Melkebeek Scribe: Tyson Williams In this lecture, we introduce the notion of a universal machine, develop efficient universal

### ! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. #-approximation algorithm.

Approximation Algorithms 11 Approximation Algorithms Q Suppose I need to solve an NP-hard problem What should I do? A Theory says you're unlikely to find a poly-time algorithm Must sacrifice one of three

### Practice Problems for Final Exam: Solutions CS 341: Foundations of Computer Science II Prof. Marvin K. Nakayama

Practice Problems for Final Exam: Solutions CS 341: Foundations of Computer Science II Prof. Marvin K. Nakayama 1. Short answers: (a) Define the following terms and concepts: i. Union, intersection, set

### 3515ICT Theory of Computation Turing Machines

Griffith University 3515ICT Theory of Computation Turing Machines (Based loosely on slides by Harald Søndergaard of The University of Melbourne) 9-0 Overview Turing machines: a general model of computation

### CMPSCI611: Approximating MAX-CUT Lecture 20

CMPSCI611: Approximating MAX-CUT Lecture 20 For the next two lectures we ll be seeing examples of approximation algorithms for interesting NP-hard problems. Today we consider MAX-CUT, which we proved to

### SOLVING NARROW-INTERVAL LINEAR EQUATION SYSTEMS IS NP-HARD PATRICK THOR KAHL. Department of Computer Science

SOLVING NARROW-INTERVAL LINEAR EQUATION SYSTEMS IS NP-HARD PATRICK THOR KAHL Department of Computer Science APPROVED: Vladik Kreinovich, Chair, Ph.D. Luc Longpré, Ph.D. Mohamed Amine Khamsi, Ph.D. Pablo

V. Adamchik 1 Graph Theory Victor Adamchik Fall of 2005 Plan 1. Basic Vocabulary 2. Regular graph 3. Connectivity 4. Representing Graphs Introduction A.Aho and J.Ulman acknowledge that Fundamentally, computer

### Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

Mathematics for Computer Science/Software Engineering Notes for the course MSM1F3 Dr. R. A. Wilson October 1996 Chapter 1 Logic Lecture no. 1. We introduce the concept of a proposition, which is a statement

### Complexity and Completeness of Finding Another Solution and Its Application to Puzzles

yato@is.s.u-tokyo.ac.jp seta@is.s.u-tokyo.ac.jp Π (ASP) Π x s x s ASP Ueda Nagao n n-asp parsimonious ASP ASP NP Complexity and Completeness of Finding Another Solution and Its Application to Puzzles Takayuki

### Algorithms and Data Structures

Algorithm Analysis Page 1 BFH-TI: Softwareschule Schweiz Algorithm Analysis Dr. CAS SD01 Algorithm Analysis Page 2 Outline Course and Textbook Overview Analysis of Algorithm Pseudo-Code and Primitive Operations

University of Virginia - cs3102: Theory of Computation Spring 2010 Final Exam - Comments Problem 1: Definitions. (Average 7.2 / 10) For each term, provide a clear, concise, and precise definition from

### Finite Automata and Formal Languages

Finite Automata and Formal Languages TMV026/DIT321 LP4 2011 Lecture 14 May 19th 2011 Overview of today s lecture: Turing Machines Push-down Automata Overview of the Course Undecidable and Intractable Problems

### Lecture 1: Time Complexity

Computational Complexity Theory, Fall 2010 August 25 Lecture 1: Time Complexity Lecturer: Peter Bro Miltersen Scribe: Søren Valentin Haagerup 1 Introduction to the course The field of Computational Complexity

### NP-completeness and the real world. NP completeness. NP-completeness and the real world (2) NP-completeness and the real world

-completeness and the real world completeness Course Discrete Biological Models (Modelli Biologici Discreti) Zsuzsanna Lipták Imagine you are working for a biotech company. One day your boss calls you

### Algebraic Computation Models. Algebraic Computation Models

Algebraic Computation Models Ζυγομήτρος Ευάγγελος ΜΠΛΑ 201118 Φεβρουάριος, 2013 Reasons for using algebraic models of computation The Turing machine model captures computations on bits. Many algorithms

### Lecture 19: Introduction to NP-Completeness Steven Skiena. Department of Computer Science State University of New York Stony Brook, NY 11794 4400

Lecture 19: Introduction to NP-Completeness Steven Skiena Department of Computer Science State University of New York Stony Brook, NY 11794 4400 http://www.cs.sunysb.edu/ skiena Reporting to the Boss Suppose

### Computability Theory

CSC 438F/2404F Notes (S. Cook and T. Pitassi) Fall, 2014 Computability Theory This section is partly inspired by the material in A Course in Mathematical Logic by Bell and Machover, Chap 6, sections 1-10.

### 6.080 / 6.089 Great Ideas in Theoretical Computer Science Spring 2008

MIT OpenCourseWare http://ocw.mit.edu 6.080 / 6.089 Great Ideas in Theoretical Computer Science Spring 008 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.

### The Classes P and NP. mohamed@elwakil.net

Intractable Problems The Classes P and NP Mohamed M. El Wakil mohamed@elwakil.net 1 Agenda 1. What is a problem? 2. Decidable or not? 3. The P class 4. The NP Class 5. TheNP Complete class 2 What is a

### Universality in the theory of algorithms and computer science

Universality in the theory of algorithms and computer science Alexander Shen Computational models The notion of computable function was introduced in 1930ies. Simplifying (a rather interesting and puzzling)

### Structural properties of oracle classes

Structural properties of oracle classes Stanislav Živný Computing Laboratory, University of Oxford, Wolfson Building, Parks Road, Oxford, OX1 3QD, UK Abstract Denote by C the class of oracles relative

### One last point: we started off this book by introducing another famously hard search problem:

S. Dasgupta, C.H. Papadimitriou, and U.V. Vazirani 261 Factoring One last point: we started off this book by introducing another famously hard search problem: FACTORING, the task of finding all prime factors

### Algorithm Design and Analysis Homework #6 Due: 1pm, Monday, January 9, === Homework submission instructions ===

Algorithm Design and Analysis Homework #6 Due: 1pm, Monday, January 9, 2012 === Homework submission instructions === Submit the answers for writing problems (including your programming report) through

### ON THE COMPLEXITY OF THE GAME OF SET. {kamalika,pbg,dratajcz,hoeteck}@cs.berkeley.edu

ON THE COMPLEXITY OF THE GAME OF SET KAMALIKA CHAUDHURI, BRIGHTEN GODFREY, DAVID RATAJCZAK, AND HOETECK WEE {kamalika,pbg,dratajcz,hoeteck}@cs.berkeley.edu ABSTRACT. Set R is a card game played with a

### CSE 135: Introduction to Theory of Computation Decidability and Recognizability

CSE 135: Introduction to Theory of Computation Decidability and Recognizability Sungjin Im University of California, Merced 04-28, 30-2014 High-Level Descriptions of Computation Instead of giving a Turing

### Theory of Computation Chapter 2: Turing Machines

Theory of Computation Chapter 2: Turing Machines Guan-Shieng Huang Feb. 24, 2003 Feb. 19, 2006 0-0 Turing Machine δ K 0111000a 01bb 1 Definition of TMs A Turing Machine is a quadruple M = (K, Σ, δ, s),

### Discrete Mathematics, Chapter 3: Algorithms

Discrete Mathematics, Chapter 3: Algorithms Richard Mayr University of Edinburgh, UK Richard Mayr (University of Edinburgh, UK) Discrete Mathematics. Chapter 3 1 / 28 Outline 1 Properties of Algorithms

### THE TURING DEGREES AND THEIR LACK OF LINEAR ORDER

THE TURING DEGREES AND THEIR LACK OF LINEAR ORDER JASPER DEANTONIO Abstract. This paper is a study of the Turing Degrees, which are levels of incomputability naturally arising from sets of natural numbers.

### Offline 1-Minesweeper is NP-complete

Offline 1-Minesweeper is NP-complete James D. Fix Brandon McPhail May 24 Abstract We use Minesweeper to illustrate NP-completeness proofs, arguments that establish the hardness of solving certain problems.

### 2. (a) Explain the strassen s matrix multiplication. (b) Write deletion algorithm, of Binary search tree. [8+8]

Code No: R05220502 Set No. 1 1. (a) Describe the performance analysis in detail. (b) Show that f 1 (n)+f 2 (n) = 0(max(g 1 (n), g 2 (n)) where f 1 (n) = 0(g 1 (n)) and f 2 (n) = 0(g 2 (n)). [8+8] 2. (a)

### Polynomials. Dr. philippe B. laval Kennesaw State University. April 3, 2005

Polynomials Dr. philippe B. laval Kennesaw State University April 3, 2005 Abstract Handout on polynomials. The following topics are covered: Polynomial Functions End behavior Extrema Polynomial Division

### COMS4236: Introduction to Computational Complexity. Summer 2014

COMS4236: Introduction to Computational Complexity Summer 2014 Mihalis Yannakakis Lecture 17 Outline conp NP conp Factoring Total NP Search Problems Class conp Definition of NP is nonsymmetric with respect

### What s next? Reductions other than kernelization

What s next? Reductions other than kernelization Dániel Marx Humboldt-Universität zu Berlin (with help from Fedor Fomin, Daniel Lokshtanov and Saket Saurabh) WorKer 2010: Workshop on Kernelization Nov

### Chapter 7 Uncomputability

Chapter 7 Uncomputability 190 7.1 Introduction Undecidability of concrete problems. First undecidable problem obtained by diagonalisation. Other undecidable problems obtained by means of the reduction

### Finding the Shortest Move-Sequence in the Graph-Generalized 15-Puzzle is NP-Hard

Finding the Shortest Move-Sequence in the Graph-Generalized 15-Puzzle is NP-Hard Oded Goldreich Abstract. Following Wilson (J. Comb. Th. (B), 1975), Johnson (J. of Alg., 1983), and Kornhauser, Miller and

### Theorem A graph T is a tree if, and only if, every two distinct vertices of T are joined by a unique path.

Chapter 3 Trees Section 3. Fundamental Properties of Trees Suppose your city is planning to construct a rapid rail system. They want to construct the most economical system possible that will meet the

### R u t c o r Research R e p o r t. Boolean functions with a simple certificate for CNF complexity. Ondřej Čepeka Petr Kučera b Petr Savický c

R u t c o r Research R e p o r t Boolean functions with a simple certificate for CNF complexity Ondřej Čepeka Petr Kučera b Petr Savický c RRR 2-2010, January 24, 2010 RUTCOR Rutgers Center for Operations

### Generating models of a matched formula with a polynomial delay

Generating models of a matched formula with a polynomial delay Petr Savicky Institute of Computer Science, Academy of Sciences of Czech Republic, Pod Vodárenskou Věží 2, 182 07 Praha 8, Czech Republic

### Approximation Algorithms

Approximation Algorithms or: How I Learned to Stop Worrying and Deal with NP-Completeness Ong Jit Sheng, Jonathan (A0073924B) March, 2012 Overview Key Results (I) General techniques: Greedy algorithms

### Simulation-Based Security with Inexhaustible Interactive Turing Machines

Simulation-Based Security with Inexhaustible Interactive Turing Machines Ralf Küsters Institut für Informatik Christian-Albrechts-Universität zu Kiel 24098 Kiel, Germany kuesters@ti.informatik.uni-kiel.de

### Lecture 1: Oracle Turing Machines

Computational Complexity Theory, Fall 2008 September 10 Lecture 1: Oracle Turing Machines Lecturer: Kristoffer Arnsfelt Hansen Scribe: Casper Kejlberg-Rasmussen Oracle TM Definition 1 Let A Σ. Then a Oracle

### Applied Algorithm Design Lecture 5

Applied Algorithm Design Lecture 5 Pietro Michiardi Eurecom Pietro Michiardi (Eurecom) Applied Algorithm Design Lecture 5 1 / 86 Approximation Algorithms Pietro Michiardi (Eurecom) Applied Algorithm Design

### CS 3719 (Theory of Computation and Algorithms) Lecture 4

CS 3719 (Theory of Computation and Algorithms) Lecture 4 Antonina Kolokolova January 18, 2012 1 Undecidable languages 1.1 Church-Turing thesis Let s recap how it all started. In 1990, Hilbert stated a

### Reminder: Complexity (1) Parallel Complexity Theory. Reminder: Complexity (2) Complexity-new

Reminder: Complexity (1) Parallel Complexity Theory Lecture 6 Number of steps or memory units required to compute some result In terms of input size Using a single processor O(1) says that regardless of

### Reminder: Complexity (1) Parallel Complexity Theory. Reminder: Complexity (2) Complexity-new GAP (2) Graph Accessibility Problem (GAP) (1)

Reminder: Complexity (1) Parallel Complexity Theory Lecture 6 Number of steps or memory units required to compute some result In terms of input size Using a single processor O(1) says that regardless of

### Complexity Theory. Jörg Kreiker. Summer term 2010. Chair for Theoretical Computer Science Prof. Esparza TU München

Complexity Theory Jörg Kreiker Chair for Theoretical Computer Science Prof. Esparza TU München Summer term 2010 Lecture 8 PSPACE 3 Intro Agenda Wrap-up Ladner proof and time vs. space succinctness QBF

### Factoring & Primality

Factoring & Primality Lecturer: Dimitris Papadopoulos In this lecture we will discuss the problem of integer factorization and primality testing, two problems that have been the focus of a great amount

### 2.1 Complexity Classes

15-859(M): Randomized Algorithms Lecturer: Shuchi Chawla Topic: Complexity classes, Identity checking Date: September 15, 2004 Scribe: Andrew Gilpin 2.1 Complexity Classes In this lecture we will look