As we have discussed in class, we have focused thus far on finding classes of problems that fit an algorithm type (greedy, divide and conquer, dynamic programming, etc). In this chapter we look instead at a new classification. Basically, we have problems that can be solved in a "short time" (polynomial) and ones that require vast amounts of time because of the numerous possibilities inherent in the problems (nonpolynomial). Reasons why from Garey and Johnson
We have an interesting aspect of Computer Science here since in studying the Theory of NP-Completeness, we do not provide a method of obtaining polynomial time algorithms, nor do we say that algorithms of this complexity do not exist.
Specifically, the focus of the study is to show that problems for which we have no known polynomial time algorithms are computationally related.
Within this group, we further differentiate the classification into smaller divisions: NP-Hard and NP-Complete.
NP stands for Nondeterministic Polynomial
Up to now, we have focused on problems that were deterministic. (Even with our AI - we still used functions to determine a path given the information known)
Discussing nondeterministic algorithms requires three new functions:
Algorithm 11.1 Nondeterministic search
Consider A machine capable of executing a nondeterminsistic algorithm in this way is called a nondeterministic machine.
Decision problems: yes/no answer. Hence we are now limited to just Success and Failure answers (output).
Although this may sound very restrictive, note that many optimization problems can be recast into decision problems with the property that the decision problem can be solved in polynomial time iff the optimization problem can. Similarly, we can say that if the decision problem cannot be solved in polynomial time, then the optimization problem cannot either.
Most of this chapter demonstrates the theory of NP through examples. The most commonly seen are Hamiltonian Cycles, Cliques, Traveling Salesperson, Node Cover, Scheduling and Satisfiability. We will look at each of these in varied respects. Here is the first:
Directed vs. undirected
L1 : does G-> have a directed Hamiltonian cycle?
L2 : does G have an undirected Hamiltonian cycle?
L1, L2 are both decision problems.
Given the above two questions, one might also be led to consider
Does L1 Does L2 Why? Hint: Humans are lazy ... if we have one, we potentially have the other
Consider:
Clearly a straightforward transformation does not work, HC on G does not imply a HC on G-> Ahhh, but be careful - this G-> is not what we would get if we had this G as a start.
Let's consider one at a time. How to solve for a Hamiltonian cycle - clearly the undirected appears easiest. Why? Let's try to ultimately "remodel" the directed so that it is easy too.
Two possibilities for solving the problem (more specifically, what is the problem?):
Obviously it is easy to see if such exist in undirected - any trick to make directed easier?
In a directed graph, each edge has two parts, a tail and a head. Hence each node can be considered as two parts - the tail and/or head of some edge.
Nodes become what looks like edges (3 nodes for each initial 1) and edges become what looks like ordered pairs of nodes. (Remember tails are at the bottom (or 3's))
G-> = (V->,E->)
V = {<u,1>, <u,2>, <u,3> | u
E = {(<u,3>, <v,1>) | <u,v>-> Here is one that has a Hamiltonian cycle
Here are some that do not
Could you write an algorithm given this nifty technique?
THM: G-> has a DHC iff G has an UHC
Proof:
==> { G-> has a DHC => G has an UHC }
Let DC = u1, u2, u3, ..., un
Then (uj, uj+1)->
<== { G has a UHC => G-> has an DHC }
Case
UHC
Therefore UHC and DHC are polynomially equivalent since each can be reduced to the other in polynomial time.
// Does G contain a Hamiltonian Cycle?
p = choice ( all permutations of V)
let p = u1, u2, u3, ..., un
if ((u1, u2)
Look how easy decidability algorithms are :-)
You may be thinking, "this all seems silly and trivial". Why do we consider decidability? It helps us determine if a problem
is NP: Again, these classifications are going to be quite useful. But make sure you know the difference between
For example, consider this interesting relationship:
L1
L1 : DHC
L2 : Traveling Salesperson Problem (tour of minimum cost)
Given a directed graph G-> = (V, E->) and c: E-> --> R,
find a DHC in G-> of minimum cost
If we know how to get a cycle with minimum cost, then we should be able to get the answer
for just the cycle! (i.e., a DHC)
A problem that is NP-Complete has the property that it can be solved in polynomial time iff all other NP-Complete problems can also be solved in polynomial time. If an NP-Hard problem can be solved in polynomial time, then all NP-Complete problems can be solved in polynomial time. All NP-Complete problems are NP-Hard, but not all NP-Hard problems are NP-Complete. (more on these definitions later)
Nondeterministic Algorithms
Algorithms such that the result of every operation is uniquely defined are called deterministic algorithms.
A nondeterministc algorithm terminates unsuccessfully if and only if there exists no set of choices leading to a successful signal.
The computing times for Choice, Success, and Failure are taken to be O(1).
time for Search for (1) deterministic (2) nondeterministic. Consider sort time for (1) deterministic (2) nondeterministic. See text, algorithm 11.2 for nondeterministic Sort.
A deterministic interpretation of a nondeterministic algorithm can be made by allowing unbounded parallelism in computation. In theory, each time a choice is to be made, the algorithm makes several copies of itself. One copy is made for each of the possible choices. Thus many copies are executing at the same time. The first copy to reach a successful completion terminates all other computations. If a copy reaches a failure completion, then only that copy of the program terminates. Although this interpretation may enable one to better understand nondeterministic algorithms, it is important to remember that a nondeterministic machine does not make any copies of an algorithm every time a choice is made. Instead it has the ability to select a "correct" element from the set of allowable choices (if such an element exists) every time a choice is to be made.
Let us go one step further: It would be nice if we even knew if there was such an choice! (Consider - is there a proof for x?)
Decision problems
Definition 11.1: Any problem for which the answer is either zero or one is called a decision problem. An algorithm for a decision problem is termed a decision algorithm. Any problem that involves the identification of an optimal solution (either maximum or minimum) value of a given cost function is known as an optimization problem. An optimization algorithm is used to solve an optimization problem.Hamiltonian cycle
Let G= (V, E) be a connected graph. A Hamiltonian cycle is a round-trip path along n edges of G that visits every vertex once and returns to its starting position (book, page 365 see figure 7.15 as well).
No H.C.
L2?
L1?
OK,
Consider possibilities: 4 nodes in the graph implies that we need 4 nodes and 4 edges for the HC, and also that each node will have a degree of 2. We see multiple choices for the undirected graph, but all do not transform to the directed.


Consider a transformation to make the directed "look" undirected.
The bottom represents when a node starts at a tail (things I point to)
The top when a node ends at a head (things pointing to me). Can we formalize this?


Suppose DC is a Hamiltonian Cycle in G->
Suppose <uj, k>
is a node on an UHC (Say UC)
DONE
then the nodes adjacent to <uj, k> on UC must be <uj, 1> and <uj, 3>
then <uj, 2> must be one of the neighbors of <uj, k > on UC
otherwise <uj, 2 > cannot lie on UC.
Also, the other neighbor must be <ul, 3 > for some l != j.
neighbors must be <uj, 2 > and <ul, 1 > for some l != j.
DHC trivial discuss
Back to Decidability and NP Algorithms
The Question: Does a graph G contain a Hamiltonian Cycle? Can you give an NP algorithm to determine this?
Algorithm DHC( G= (V, E) )
// Guess
then return('Success')
else return('Failure')
* reductions (which require valid transformations),
* NP algorithms,
* and decision problems.
L2 imples L1 is a special case of L2

Algorithm DHC(G-> = (V, E->))
// construct
end DHC

// edges added on to complete graph
HC = TSP(G->, c)
if c(HC) = |V| then return(YES)
else return(NO)