# CMPSCI 311: Theory of Algorithms

### Polynomial-Time Reductions

The most important definition in the theory of NP-completeness is the polynomial-time reduction. Let A and B be two sets of inputs, which we can think of as two problems with boolean answers. A reduction from A to B is a function f such that (1) f is easily computable (computable in polynomial time), and (2) for any input x, x is in A if and only if f(x) is in B.

A reduction from A to B gives us an easy way to answer ``is x in A'' if we know an easy way to answer questions about B -- we compute f(x) and decide whether f(x) is in B.

In this exercise we will construct some reductions. In each case B will be the REACHABILITY problem, the set {(G,s,t): G is a directed graph and there is a path form vertex s to vertex t in G}.

• Question 1: Reduce COMPLETE to REACHABILITY, where COMPLETE is the set {G: G is an undirected graph that has all possible edges in it}. Your reduction does not have to solve COMPLETE, though this is easy -- it should create a graph H and vertices s and t in H such that H has a path from s to t if and only if G is complete.

• Question 2: Reduce the problem MAJORITY to REACHABILITY, where MAJORITY is the set {w: w is a string of 0's and 1's and at least half the letters of w are 1's}.

• Question 3: Reduce STRONGLY-CONNECTED to REACHABILITY, whree STRONGLY-CONNECTED is the set {G: G is a directed graph such that for every pair of vertices u and v in G, there is an path from u to v in G}.