CS 125 Section #10 Midterm 2 Review 11/5/14

Similar documents
Exercises Computational Complexity

Theory of Computations Spring 2016 Practice Final Exam Solutions

1. Draw the state graphs for the finite automata which accept sets of strings composed of zeros and ones which:

CS521 \ Notes for the Final Exam

CS 125 Section #6 Graph Traversal and Linear Programs 10/13/14

Computational problems. Lecture 2: Combinatorial search and optimisation problems. Computational problems. Examples. Example

CMPSCI 250: Introduction to Computation. Lecture 20: Deterministic and Nondeterministic Finite Automata David Mix Barrington 16 April 2013

END-TERM EXAMINATION

We ve studied the main models and concepts of the theory of computation:

CSE Qualifying Exam, Spring February 2, 2008

Midterm Exam II CIS 341: Foundations of Computer Science II Spring 2006, day section Prof. Marvin K. Nakayama

CS 181 EXAM #1 NAME. You have 90 minutes to complete this exam. You may state without proof any fact taught in class or assigned as homework.

Theory of Computations Spring 2016 Practice Final

NP-complete Reductions

P and NP (Millenium problem)

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

Chapter 9 Graph Algorithms

CMPSCI611: The SUBSET-SUM Problem Lecture 18

Theory Bridge Exam Example Questions Version of June 6, 2008

CS6160 Theory of Computation Problem Set 2 Department of Computer Science, University of Virginia

Notes for Lecture 24

1. [5 points each] True or False. If the question is currently open, write O or Open.

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Algorithms For Inference Fall 2014

Final Exam May 8, 2018

Solving problems on graph algorithms

NP-Completeness. Algorithms

I have read and understand all of the instructions below, and I will obey the Academic Honor Code.

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

Solutions for the Exam 6 January 2014

Questions? You are given the complete graph of Facebook. What questions would you ask? (What questions could we hope to answer?)

CSE 105 THEORY OF COMPUTATION

Jessica Su (some parts copied from CLRS / last quarter s notes)

Chapter 9 Graph Algorithms

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

ALGORITHMS EXAMINATION Department of Computer Science New York University December 17, 2007

CSE 417 Network Flows (pt 3) Modeling with Min Cuts

Dynamic Programming. CSE 101: Design and Analysis of Algorithms Lecture 19

1. (10 points) Draw the state diagram of the DFA that recognizes the language over Σ = {0, 1}

Best known solution time is Ω(V!) Check every permutation of vertices to see if there is a graph edge between adjacent vertices

CS 125 Section #5 Graph Traversal and Linear Programs October 6, 2016

Equivalence of NTMs and TMs

Introduction to Algorithms. Lecture 24. Prof. Patrick Jaillet

Practice Final Exam 1

Department of Computer Applications. MCA 312: Design and Analysis of Algorithms. [Part I : Medium Answer Type Questions] UNIT I

Examples of P vs NP: More Problems

Contents. CS 124 Final Exam Practice Problem 5/6/17. 1 Format and Logistics 2

Lecture 7: Counting classes

Complexity Classes and Polynomial-time Reductions

Final. Name: TA: Section Time: Course Login: Person on Left: Person on Right: U.C. Berkeley CS170 : Algorithms, Fall 2013

Introduction to Graph Theory

NFAs and Myhill-Nerode. CS154 Chris Pollett Feb. 22, 2006.

Homework 4 Solutions

Final Course Review. Reading: Chapters 1-9

8 Matroid Intersection

6. Lecture notes on matroid intersection

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

Chapter 9 Graph Algorithms

8 NP-complete problem Hard problems: demo

NP-Hardness. We start by defining types of problem, and then move on to defining the polynomial-time reductions.

CS261: Problem Set #1

1 Format. 2 Topics Covered. 2.1 Minimal Spanning Trees. 2.2 Union Find. 2.3 Greedy. CS 124 Quiz 2 Review 3/25/18

Dynamic programming. Trivial problems are solved first More complex solutions are composed from the simpler solutions already computed

CS161 - Final Exam Computer Science Department, Stanford University August 16, 2008

Solutions to Homework 10

Some Hardness Proofs

Decision Problems. Observation: Many polynomial algorithms. Questions: Can we solve all problems in polynomial time? Answer: No, absolutely not.

NP-Complete Problems

CS1800 Discrete Structures Final Version B

1 Better Approximation of the Traveling Salesman

CS 125 Section #4 RAMs and TMs 9/27/16

Introduction to Algorithms

NP-Complete Problems

CS103 Handout 13 Fall 2012 May 4, 2012 Problem Set 5

W[1]-hardness. Dániel Marx. Recent Advances in Parameterized Complexity Tel Aviv, Israel, December 3, 2017

(Refer Slide Time: 0:19)

Jörgen Bang-Jensen and Gregory Gutin. Digraphs. Theory, Algorithms and Applications. Springer

Approximation Algorithms

More on Polynomial Time and Space

2. True or false: even though BFS and DFS have the same space complexity, they do not always have the same worst case asymptotic time complexity.

Material from Recitation 1

Greedy Algorithms 1. For large values of d, brute force search is not feasible because there are 2 d

Ideally your algorithms for both parts should run in linear time. You will receive partial credit for a polynomial-time algorithm.

Problem set 2. Problem 1. Problem 2. Problem 3. CS261, Winter Instructor: Ashish Goel.

Lecture 11: Maximum flow and minimum cut

CSE 417 Network Flows (pt 4) Min Cost Flows

Extra Practice Problems 2

Vertex Cover Approximations

Recitation 4: Elimination algorithm, reconstituted graph, triangulation

CS 181 B&C EXAM #1 NAME. You have 90 minutes to complete this exam. You may assume without proof any statement proved in class.

Shortest Path Problem

CS490 Quiz 1. This is the written part of Quiz 1. The quiz is closed book; in particular, no notes, calculators and cell phones are allowed.

Shortest path problems

CS270 Combinatorial Algorithms & Data Structures Spring Lecture 19:

Theory of Computation, Homework 3 Sample Solution

6 NFA and Regular Expressions

Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest. Introduction to Algorithms

CMPSCI 311: Introduction to Algorithms Practice Final Exam

Module 6 NP-Complete Problems and Heuristics

Module 6 P, NP, NP-Complete Problems and Approximation Algorithms

6.2. Paths and Cycles

Transcription:

CS 125 Section #10 Midterm 2 Review 11/5/14 1 Topics Covered This midterm covers up through NP-completeness; countability, decidability, and recognizability will not appear on this midterm. Disclaimer: This is not a comprehensive list of possible topics for the exam; in general, any material from lecture, homeworks, or sections is fair game. 1.1 Models of Computation DFA: Accept if we end at an accept state NFA: Accept if any computation path ends at an accept state Turing Machine (TM): DFA with a memory tape and a head that moves along the tape. Also, NTMs, which are the nondeterministic variant. Word-RAM: Program with random memory access but a finite number of registers to work with. 1.2 Power of Computation Regular Language. A language accepted by a DFA. This is the same as languages accepted using NFAs (proven using the subset construction). However, the smallest DFA may have exponentially many states compared to the smallest NFA. Ways to show that a language is/isn t regular: Myhill-Nerode: A language L is regular iff there are only finitely many equivalence classes under the equivalence relation x y iff for all strings z, xz L yz L. The minimum number of states in a DFA for L is exactly the number of equivalence classes under. Constructions with NFAs and/or DFAs Closure properties (union, intersection, complement, homomorphism, inverse homomorphism) - these were covered in section 8 / problem set 7. The standard TM is computationally equivalent to many variants (multi-tape TM, TM with bidirectional tape, etc.). A word-ram can simulate a TM. A TMs can simulate a word-ram with only quadratic slowdown. 1.3 Complexity Classes P: the set of languages that can be decided by a deterministic TM in polynomial time NP: the set of languages that can be decided by a deterministic TM in polynomial time 1

Alternate characterization: the set of languages for which there exists a polynomial time verifier V such that for any x, there exists a certificate y with V (x, y) = 1 if and only if x is in the language. The idea is that an answer is easy to check once we have one. conp is the set of languages whose complements are in NP (problem set 8). While the languages above are formulated as decision problems, as we have seen, we can often use the decision problem to solve the search/optimization problem with only polynomial slowdown. 1.4 Reductions NP-complete problems are ones that are both in NP and are NP hard. Examples we ve seen include Sat, 3-Sat, Clique, Vertex Cover, Integer Linear Programming. We usually show that a language L is NP-complete (or complete for some other class) by giving a reduction from some language L which we already know to be NP-complete. That is, we give some polynomial-time computable function f such that x L f(x) L. The intuition behind this is that if we know how to solve L, then we know can use that to solve L thus, L must be an easier problem to solve than L. 1.5 Algorithms You should be able to run any of these algorithms by hand on the exam; you should also be familiar with their runtimes and/or space requirements. Pattern Recognition using DFAs. Depth First Search and Breadth First Search. Shortest-path algorithms & negative cycle detection: Djikstra s Algorithm (single-source). Modified BFS. Bellman-Ford (single-source). Successive approximation: repeatedly look at through the edges and see if any edge gives a shorter path to its endpoint than what we have already found. Floyd-Warshall (all pairs). Dynamic programming, with the subproblems looking at paths which can only use a subset of the vertices. Linear Programming. Maximize a linear function given a set of linear constraints. Zero-sum Games. Reduce to linear programming or solve by hand. Network flows: Max flow = min cut Can reduce this to linear programming Augmenting Paths. Keep trying to find a path in the residual network where we can push more flow across. Stop when we are no longer able to do so; at this point, the set of vertices reachable in the residual network from the source defines a minimum cut. 2

2 Practice Problems 2.1 Shortest Paths and Linear Programming Exercise. In section, we already saw a way to formulate the shortest path problem as a linear program, by using a variable on each edge to denote whether or not it is included. Now, consider the LP subject to maxd t d v d u + w(u, v) for all edges (u, v) E d s = 0 Argue that this LP finds the length of the shortest path from s to t. Show how to extend the above LP to find the length of the shortest paths from s to every vertex in the graph. (Assume the shortest paths are finite for simplicity.) Exercise. You re playing a new mobile phone game, Very Happy Pigs, and are having trouble on the latest level. You decide to model the level as a directed graph, where each vertex represents a platform you can reach, and each edge represents a jump you can try to make. After extensive experimentation, youve labeled each edge with the probability (a number in [0, 1]) that you can successfully make the jump. Unfortunately, if you fail to make any jump, you instantly die, and have to start over. Describe an efficient algorithm to find a path from the start platform to the goal platform that maximizes the probability of getting through the level. You should assume that whether you make a certain jump of not is independent of all other jumps. 3

2.2 Zero-Sum Games Exercise. Consider the following zero-sum game, where the entries denote the payoffs of the row player: 1 4 3 7 2 1 5 2 2 Write the linear programs for both players. Exercise. How would the answer to the previous problem change if the payoffs were to the column player? 2.3 Network Flows Exercise. The edge connectivity of an undirected graph is the minimum number k of edges that must be removed to disconnect the graph. For example, the edge connectivity of a tree is 1, and the edge connectivity of a cyclic chain of vertices is 2. Show how the edge connectivity of an undirected graph G = (V, E) can be determined by running a maximum-flow algorithm on at most V flow networks, each having O(V ) vertices and O(E) edges. 4

2.4 Regular Languages Exercise. TRUE or FALSE? Justify your answers in one or two sentences. 1. If 3-SAT P, then the Travelling Salesman Problem is in P. 2. There is an algorithm that decides SAT in exponential time. 3. If L is regular, then L = {x L : x is not a multiple of 2014} is also regular. 4. If L is regular, then L = {x L : x > 2009} is also regular. 5. Every infinite subset of a non-regular language is non-regular. 6. The complement of any non-regular language is non-regular. 7. If every state of an NFA N is final, then L(N) = Σ. Exercise. For each of the following languages, say whether it is regular or not. Briefly justify your answers. 1. L = {a n b n a n : n 0} 2. L = {w : w contains both obama and romney as substrings}, over alphabet Σ = {a, b,..., z} 3. L = {wa n : w {a, b}, n = the number of a s in w}. 4. L = {w {a, b} : w has at least 2 b s or at least 2 a s} 5. {a 5n b 2m c 5p : m, n, p 0} 6. The set of strings over alphabet {a, b} in which every b is both preceded by an a and followed by an a. 7. L = {a 3i b 5j : i, j N}. 5

Exercise. For any language L, let Copy(L) = {w n : w L, n 0}. 1. Prove that if L is finite, then Copy(L) is regular. 2. Prove that if L is regular, then Copy(L) need not be regular. Exercise. For a string w = w 1 w n, we consider a proper prefix to be a substring of the form w 1 w k for some 0 < k < n. Prove that if L is regular then PrefixFree(L) = {w : w L and no proper prefix of w is in L} is also regular. 2.5 Polynomial Time Complexity Exercise. For an integer N, let let N B denote the binary representation of N (over alphabet {0, 1}) and N U denote the unary representation of N (i.e. a string of N ones). For each of the following two functions, state whether it is computable in polynomial time and justify your answer. You may quote without proof basic facts about the complexity of arithmetic operations (e.g. addition and multiplication). 1. BinaryToUnary( N B ) = N U. 2. UnaryToBinary( N U ) = N B. 6

2.6 NP-completeness Exercise. TRUE or FALSE? Justify your answers in one or two sentences. 1. Every NP-hard language is NP-complete. 2. If there is a polynomial-time mapping reduction from A to B (i.e. A p B) and B is in NP, then A is in NP. Exercise. SetCover is the following problem: given a finite universe U, a family of subsets S 1,..., S n U, and a number l N, are there l of the sets S i whose union equals the entire universe U? Prove that SetCover is NP-complete. (Hint: recall the NP-complete problem VertexCover: given a graph G and a number k, determine whether there is a set of k vertices that includes an endpoint of every edge in G.) Exercise. Consider the following two languages, whose instances are of the form G, k where G is an undirected graph and k is a natural number: Clique consists of all G, k for which there is a set S of k vertices in such that every pair of vertices in S are connected by an edge in G. Independent Set consists of all G, k for which G has a set S of k vertices such that no pair of vertices in S is connected by an edge in G. In lecture, we proved that Clique is NP-complete. Show that Independent Set is also NP-complete. 7

Exercise. 1. Prove that Cubic Equations modulo 2, that is, the problem of deciding, given a system of equations modulo 2 over several integer variables where each term has total degree at most 3, whether the system has a solution, is NP-complete. (Hint: reduce from 3-SAT.) 2. (Challenge) Prove that Quadratic Equations modulo 2, which is defined analogously, is NPcomplete. (Hint: reduce the degree of a monomial x i x j x k by introducing another variable and another equation.) 8