# Difference between revisions of "Chapter 12"

=Dealing with Hard Problems=\

## Contents

### Special Cases of Hard Problems

12.1. Dominos are tiles represented by integer pairs $(x_{i},y_{i})$ , where each of the values $x_{i}$ and $y_{i}$ are integers between 1 and $n$ . Let $S$ be a sequence of m integer pairs $[(x_{1},y_{1}),(x_{2},y_{2}),...,(x_{m},y_{m})]$ . The goal of the game is to create long chains $[(x_{i1},y_{i1}),(x_{i2},y_{i2}),...,(x_{it},y_{it})]$ such that $y_{ij}=x_{i(j+1)}$ . Dominos can be flipped, so $(x_{i},y_{i})$ equivalent to $(y_{i},x_{i})$ . For $S=[(1,3),(4,2),(3,5),(2,3),(3,8)]$ , the longest domino sequences include $[(4,2),(2,3),(3,8)]$ and $[(1,3),(3,2),(2,4)]$ .
(a) Prove that finding the longest domino chain is NP-complete.
(b) Give an efficient algorithm to find the longest domino chain where the numbers increase along the chain. For S above, the longest such chains are $[(1,3),(3,5)]$ and $[(2,3),(3,5)]$ .

12.2. Let $G=(V,E)$ be a graph and $x$ and $y$ be two distinct vertices of $G$ . Each vertex $v$ contains a given number of tokens $t(v)$ that you can collect if you visit $v$ .
(a) Prove that it is NP-complete to find the path from $x$ to $y$ where you can collect the greatest possible number of tokens.
(b) Give an efficient algorithm if $G$ is a directed acyclic graph (DAG).

12.3. The Hamiltonian completion problem takes a given graph $G$ and seeks an algorithm to add the smallest number of edges to $G$ so that it contains a Hamiltonian cycle. This problem is NP-complete for general graphs; however, it has an efficient algorithm if $G$ is a tree. Give an efficient and provably correct algorithm to add the minimum number of possible edges to tree $T$ so that $T$ plus these edges is Hamiltonian.

### Approximation Algorithms

12.4. In the maximum satisfiability problem, we seek a truth assignment that satisfies as many clauses as possible. Give an heuristic that always satisfies at least half as many clauses as the optimal solution.

12.5. Consider the following heuristic for vertex cover. Construct a DFS tree of the graph, and delete all the leaves from this tree. What remains must be a vertex cover of the graph. Prove that the size of this cover is at most twice as large as optimal.

12.6. The maximum cut problem for a graph $G=(V,E)$ seeks to partition the vertices $V$ into disjoint sets $A$ and $B$ so as to maximize the number of edges $(a,b)\in E$ such that $a\in A$ and $b\in B$ . Consider the following heuristic for maximum cut. First assign $v_{1}$ to $A$ and $v_{2}$ to $B$ . For each remaining vertex, assign it to the side that adds the most edges to the cut. Prove that this cut is at least half as large as the optimal cut.

12.7.  In the bin-packing problem, we are given n objects with weights $w_{1},w_{2},...,w_{n}$ , respectively. Our goal is to find the smallest number of bins that will hold the $n$ objects, where each bin has a capacity of at most one kilogram.
The first-fit heuristic considers the objects in the order in which they are given. For each object, place it into the first bin that has room for it. If no such bin exists, start a new bin. Prove that this heuristic uses at most twice as many bins as the optimal solution.

12.8. For the first-fit heuristic described just above, give an example where the packing it finds uses at least 5/3 times as many bins as optimal.

12.9. Given an undirected graph $G=(V,E)$ in which each node has degree ≤ d, show how to efficiently find an independent set whose size is at least $1/(d+1)$ times that of the largest independent set.

12.10. A vertex coloring of graph $G=(V,E)$ is an assignment of colors to vertices of $V$ such that each edge $(x,y)$ implies that vertices $x$ and $y$ are assigned different colors. Give an algorithm for vertex coloring $G$ using at most $\Delta +1$ colors, where $\Delta$ is the maximum vertex degree of $G$ .

12.11. Show that you can solve any given Sudoku puzzle by finding the minimum vertex coloring of a specific, appropriately constructed (9×9)+9 vertex graph.

12.12

12.13

12.14

12.15

12.16

12.17

12.18

### "Quantum" Computing

12.19

12.20

12.21

12.22

Back to Chapter List