G13CS3 -- Math'l Aspects of Computing

Exercises 3 -- Solutions

  1. We transform Hamiltonian Path [HP] to Longest Path [LP]. Given an instance of HP, construct the instance of LP which has the same graph and for which the given number of edges is one less than the number of nodes in the graph. This construction can be carried out in polynomial time [indeed in linear time, for it is necessary merely to copy the graph and count its vertices], and this instance of LP clearly has the same decision as the instance of HP. Further, LP is in NP, for an oracle could suggest a suitable path, which could be checked in polynomial time, in cases where the decision is `yes'; hence, since HP is NP-complete, so must be LP. [That is, any decision problem D in NP can be transformed in polynomial time to an instance of HP and hence to an instance of LP with the same decision.]

  2. Following the hint, we transform from Vertex Cover [VC]. Given an instance of VC, we construct an instance of Clique as follows: firstly, construct the complementary graph -- that is, the graph in which a pair of vertices is joined if and only if they are not joined in the original -- to the graph of the instance of VC; secondly, find the integer k = n - p, where n is the number of vertices in the [either!] graph, and p is the proposed number of vertices in the cover. This construction can be carried out in time polynomial in n, and hence in the size of the instance of VC. Now ask whether the complementary graph has a clique of size k. If so, then all edges joining vertices in this clique are in the complementary graph, and hence any edges in the original graph are incident on at least one of the remaining p vertices, and hence the original graph has a cover of size p. Conversely. if the original graph has a cover of size p, then it contains no edge joining any pair of the remaining k vertices, and hence these form a clique in the complementary graph.

    So, the instance of VC and the constructed instance of Clique have the same decision. Clique is in NP, for, given a `yes' instance of Clique, an oracle could propose a suitable set of vertices which could be checked in polynomial time. Since VC is NP-complete, it follows that Clique too is NP-complete; that is, any decision problem D in NP can be transformed in polynomial time into an instance of VC and hence into an instance of Clique with the same decision.


E-mail: [my initials] [at] cuboid.me.uk, home page: http://cuboid.me.uk/anw.

Copyright © Dr A. N. Walker, 1997, 2016.