

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


(a) Goal on first day of class with asymptotic notation: create a rough set of classes of complexity: can be thought of as sets of problems that have same “level of difficulty” to solve. Have seen many different upper bounds on problems (O(log N ), O(N ), O(N 2 ), O(N k^ ), O(2N^ ),.. .). (b) Problem is as difficult to solve as its best algorithms running time: belongs in same class as other problem with same running time. (c) Example: sorting and heap construction are in the same class: O(N log N ). (d) For most algorithms we’ve looked at, running time was a small polynomial with respect to the input size. If the input size doubles, the running time only increases by constant factor. (e) This is our definition of a “good” solution and those with such solutions are generally known as “well-solved” problems. (f) More Formally: Complexity Classes i. Let TIME(f (n)) denote the set of problems solvable in time O(f (n)). ii. TIME(n^2 ) = {Sorting, FindMinimum, TopologicalSort, ...} iii. All Pairs Shortest Path is not in TIME(n^2 ). iv. Complexity class P =
k> 0 TIME(nk^ ). v. P is the set of all problems solvable in “polynomial time”. vi. Polynomial time is “good”. vii. Most problems we have encountered are in P; many more are not. (g) Eulerian Circuits i. Problem: Does a given graph contain a circuit that travels each edge once and only once? ii. Easy solution: if degree of every vertex is even, then the answer is yes. (h) Hamiltonian Cycles i. Problem: given a graph, does it contain a cycle that visits each vertex in the graph exactly once? ii. |V |! permutations of vertices to be checked. (i) Traveling Salesman Problem i. Problem: what is the minimum length tour that visits each vertex of a given graph exactly once? ii. Simple greedy solution is not optimal. iii. Again, |V |! permutations of vertices. (j) Decision Problems / Optimization Problems i. Hamiltonian Path is a decision problem: the answer is yes or no. ii. TSP is an optimization problem: the answer is an optimal tour. iii. We can convert an optimization problem into a decision problem. iv. Example: TSP: does there exist a tour of length L or less? (k) Verification (of a Problem Solution) i. Sorting: given a permutation, are the elements sorted? ii. Can be verified in O(N ) time. iii. Find Minimum: given a list element, is it the minimum? iv. Can be verified in O(N ) time. v. Hamiltonian Cycle: given a permutation of vertices, is it a legal cycle? vi. Can be verified in O(|V | + |E|) time (given a permutation of vertices, check that there is an edge between each consecutive vertex).
vii. TSP: given a tour, does it cover all cities in length less than L? viii. Can be verified in O(|V | + |E|) time (add up the length of the tour and see if it is less than L and visits all cities). ix. All are verifiable in “polynomial time”. (l) Solving and Verifying i. Obviously “verifiability” in O(f (n)) does not imply “solvability” in O(f (n)). ii. Example: Hamiltonian Path: solution can be verified in polynomial time; however, an expo- nential number of possible permutations. iii. “Solvability” in time O(f (n)) does not imply “verifiability” in time O(f (n)).
(m) “Nondeterministic” Algorithms
i. There are two stages to a non-deterministic algorithm: a guessing stage and a verification stage. ii. Example: TSP: 1) non-deterministically guess a tour (in time O(n)). 2) verify that the guessed tour is a (valid) solution. iii. Notion of being “solved”: if there exists a solution to an instance I of the given problem, then some answer S that we guessed non-deterministically will lead the checking stage to detect a solution (and output “yes”). Conversely, if there is not a solution to instance I, nothing we guess will be right and the checking stage will always answer “no”. iv. Example. (n) The Class NP i. NP is defined by nondeterministic algorithms. ii. Let the set NTIME(f (n)) = the set of problems that can be solved in O(f (n)) by nondeter- ministic algorithms. iii. Then complexity class NP =
k> 0 NTIME(n k (^) ). iv. NP is the set of problems that can be solved in “polynomial time” by nondeterministic algorithms. v. The Hamiltonian Path Problem and TSP are in NP. vi. The “guessing stage” can only take polynomial time. vii. The size of the guess must be polynomial with respect to the input size. viii. The “guess” must be verified in polynomial time. (o) P and NP i. Obviously, P ⊆ NP. ii. It is believed that P 6 = NP. iii. Implication: a problem in NP that is not in P would require more than polynomial time to solve. iv. Famous open problem. Answer is yet unknown. (p) NP-complete i. A special property of a subset of NP (sometimes referred to as its own complexity class) defined as follows: if problem L is NP-complete, then it must be in the set NP and it must be “as hard” as any problem in NP. ii. In other words, for any given problem L that is NP-complete, if you find a polynomial time solution for L, then you have found a polynomial time solution for all problems in NP. iii. These are the “hardest” problems of NP. iv. Many every-day problems have been proven NP-complete: Hamiltonian Cycle, TSP, Longest Path, etc. (q) P = NP i. It would be nice to prove this; to date, no one has.