<<

A Brief Overview of Complexity

Introduction

One of the goals of complexity theory is to develop techniques that allow one to determine the intrinsic complexity of a problem, meaning a worst-case lower bound on the amount of time and/or memory that is required to solve the problem. Currently this goal seems far from being fully achieved, as only a handful of results exist that establish the intrinsic complexity of a problem.

Perhaps the most well-known lower-bound result is that for sorting an array of n integers by using pairwise comparisons (as is done in algorithms, such as Mergesort and Quicksort). Here it can be shown that the best algorithm will require a worst-case of Ω(n log n) such comparisons.√ For example,√ there is no sorting (by pairwise comparisons) algorithm that runs in time O(n log n), since n log n = o(n log n).

Currently, most of the important complexity results deal with relativized complexity (as opposed to absolute complexity), in which one problem is proved to be just as complex as another. These results have the form “if problem A is hard, then so is problem B”, where “hard” means having some undesirable complexity, such as having a running time that is superpolynomial in the worst case. Relativized complexity results are usually obtained by way of reduction from one problem to another. For example, if I suspect problem A is hard (since there is no known efficient algorithm for solving A), but I know how to efficiently translate an instance of A to an instance of B, then I should suspect that B is also hard, since an efficient algorithm for B implies an efficient one for A.

To better appreciate the difficulty in establishing an absolute complexity result, as an example, suppose we are interested in proving that the best algorithm for problem A has a worst-case running time of Ω(1.5n), where n is the size of an instance of A. To do so we must prove that there is no possible algorithm that solves A in worst-case time t(n) = o(1.5n). But consider a modern-day language, such as C, Java, or Python, and imagine the infinite number of different programs that can be written with such a language. Our task then is to prove that not a single one of these programs implements an algorithm that solves A in time t(n) = o(1.5n). This seems like an almost impossible task, for the human mind seems far more comfortable with creating in a complex environment (such as the universe of possible programs), than in proving the nonexistence of some possible creation.

On an optimistic note, there exist success stories of mathematicians proving the nonexistence of algorithms. For example, after a few hundred years of failed effort, mathematicians, such as Galois,

1 Abel, and Ruffini, of the 18th and 19th centuries finally established that a polynomial equation of at least 5 has no solution that uses only addition, subtraction, multiplication, division, and roots. As another example, Alan Turing was able to resolve the Halting Problem that asks if there is an algorithm that takes as input i) a program P , and ii) an input x to P , and returns true iff the computation of P on input x halts in a finite number of steps (i.e. P does not enter an infinite loop while computing with input x).

Although the accomplishements of Galois and Turing offer some optimisim, one aspect of obtaining a complexity result for some problem A, that perhaps makes it more challenging to establish than the above-mentioned conquests, is that there do exist algorithms for solving A, but the challenge is to show that all of these algorithms require a desired lower-bound on their running time. At least up until now, there has been far more success in proving the nonexistence of an algorithm, rather than the nonexistence of an efficient algorithm.

Euler Circuits and Hamilton Cycles

Another challenge of complexity theory lies in the observation that, on the surface, problems that admit efficient algorithms often resemble other problems that do not. One of the more interesting ex- amples of this involves the two decision problems Euler Circuit (EC) and Hamilton (HC). An instance of either problem is a connected simple graph G = (V,E). For EC the problem is to determine if G admits an Euler circuit, i.e. a cycle that visits every edge e ∈ E exactly once. On the other hand, for HC the problem is to determine if G admits a Hamilton cycle, i.e. a cycle that visits every vertex v ∈ V exactly once.

Example 1. The cubic graph Qn, n ≥ 1, has vertex set equal to the set of all binary strings of length n. Moreover, two vertices are adjacent iff they differ in at most one bit place. For example, in Q3, 000 is adjacent to 010, but not to 011. Draw Q1, Q2, and Q3. Determine which of Q1,Q2,Q3 has a i) Euler circuit, ii) Hamilton cycle.

2 Theoerem 1. A connected simple graph G = (V,E) has an Euler circuit iff G every vertex of G has even degree.

Proof of Theorem 1. Let C = u = v1, v2, . . . , vn−1, vn = u be an Euler circuit for G. Since G is connected, every vertex v ∈ V must appear at least k ≥ 1 times in C. Moreover, if v 6= u, then let (r1, v, s1),..., (rk, v, sk) denote the k subsequences of C that represent moving from a vertex to v, followed by moving from v to another vertex. Then, since C is Eulerian, the 2k edges (r1, v), (v, s1),..., (rk, v), (v, sk) are all distinct, and represent all the edges incident with v. Hence deg(v) = 2k is even. The same argument also holds in case v = u, but now we must include the two additional edges (u, v1), (vn−1, u), for a total of 2k + 2 edges, k ≥ 0, which is still an even number.

Conversely, assume G is connected and every vertex of G has even degree. The graph with the smallest number of edges that satisfies this assumption is the having three vertices and three edges. This graph certainly has an Euler circuit. For the inductive step, assume that the theorem holds for all graphs with at most m − 1 edges, for some m ≥ 4. Now consider a connected graph G with m edges and for which every vertex of G has even degree. It is left as an exercise to 0 prove that G has a cycle C0. Let G denote G with all edges of C0 removed. Notice that all the vertices of G0 have even degree, since, for each v ∈ V , an even number of edges incident with v were removed in order to construct G0.

Now assume G0 is connected. Then G0 has fewer than m edges, and, by the inductive assumption, 0 G has an Euler circuit C1. Moreover, C0 and C1 must have at least one vertex v in common (why?). Thus, if we write both C0 and C1 as sequences of vertices that begin and end with v, then the concatenation of C0 with C1, denoted C = C0 · C1, is an Euler circuit for G.

0 0 Finally, assume G is not connected. Let G1,...,Gk denote the connected components of G , each of which has at least one edge (i.e. ignoring any components that consist of a single vertex). Similar to the previous case, each vertex of each must have even degree. Moreover, since each component Gi is connected and has fewer than m edges, by the inductive assumption, Gi has an Euler circuit Ci, i = 1, . . . , k. Also, C0 has a vertex in common with each of the Ci (why?). And without loss of generality we may write C0 = P1 ····· Pk · Pk+1, where Pi is a that ends with vertex vi ∈ Gi, and Ci begins and ends with vi, i = 1, . . . , k. Thus,

C = P1 · C1 ····· Ck−1 · Pk · Ck · Pk+1 is an Euler circuit for G.

Theorem 1 provides a linear-time algorithm for deciding if a connected graph has a Euler circuit. Namely, with the help of an array to keep track of the degree count of each vertex, one can iterate through the edges of G to compute each degree and return true iff all degrees are even. Thus, the algorithm does not actually find a circuit, but rather determines whether or not one exists (but note that the inductive proof of Theorem 1 provides a natural recursive method to compute a circuit if it exists).

On the other hand, it does not appear that there is an analogous efficient algorithm for determining if a connected simple graph has a Hamilton cycle. Finding such an algorithm, or priving its nonexistence, remains a central open problem for computer science. In the remaining lectures we hope to provide

3 both insight into and an appreciation of this problem that has vexed some of the greatest minds of computer science.

4 Exercises

1. A Eulerian path from vertex a to vertex b is a path that begins at a, traverses each edge exactly once, and ends at b. Prove that if a connected graph has exactly two odd-degree vertices, a and b, then there is a Eulerian path from a to b. Hint: use Theorem 1. 2. Prove that in any graph the number of vertices having odd degree is even. 3. Use the Pigeon-Hole Principle to prove that a simple graph has at least two vertices having the same degree. 4. Prove that if G is a connected graph for which each of its vertices has even degree, then G must have a cycle. Hint: you may not use Theorem 1, sine it relies on this result. 5. State a theorem analogous to Theorem 1 that holds true for strongly connected directed graphs. 6. The five Platonic solids are the cube, octahedron, dodecahedron, tetrahedron, and icosahedron. For each one, draw its graph version, in which each corner, i.e. where multiplie faces meet, represents a vertex, while two vertices are adjacent iff their respective corners are adjoined by a face edge, where two faces meet. Determine which of the five admit a Hamilton cycle. Hint: the cube’s graph version is isomorphic to Q3. 7. Consider an m × n chessboard, and a rook (chess piece that moves both horizontally and vertically) that is at square (1, 1), and desires to visit every other square exactly once before returning to (1, 1). Prove that the rook will succeed iff either m or n is even. Hint: use induction. 8. Show that the Peterson graph has a Hamilton path, i.e. a path that visits every vertex exactly once, but not a Hamilton cycle.

Figure 1: The Peterson Graph

9. Suppose you have access to an oracle that, upon receiving a graph G = (V,E), will tell you whether or not G has a Hamilton cycle. Here the “input” graph you provide the oracle is referred to as a query to the oracle. Suppose for query G = (V,E), the oracle answers “yes”. Show how to obtain an actual Hamilton cycle for G by performing at most m = |E| additional oracle queries.

5 10. Prove that if G = (V,E) is connected, and a1, b1, . . . , ak, bk ∈ V are the odd-degree vertices of G, k ≥ 1, then the edges of G can be partitioned into k paths P1,...,Pk, where Pi is a path from ai to bi. Hint: use induction on the number of edges. 11.A Chinese-Postman circuit for connected graph G is one that traverses every edge at least once. Prove that every connected graph admits a CP circuit that traverses each edge at most twice. Hint: consider a depth-first spanning T for G, along with its set of backward edges.

6 Exercise Solutions

1.

7