Combinatorial optimization, 1st midterm retake, 2019
You can receive 10 points for each problem. Reasoning is necessary. Simple answers without a reasoning worth zero points even if the answer is correct. Carefully read the problems! Some problems contain multiple parts!
1. Use Dijkstra's algorithm to calculate the distances between A and every other vertex in the left graph! Write down the table which contains the calculations and give the order that how the vertices have been put to the FINISHED set! Give a shortest path between A and F!
C
3 6 A 2
1
D
E B
F
G
H 2 2
4 2
4 5 3
8
8 12
Solution:
The table worth 6 points.
The order of the vertices who they appear in the FINISHED SET: A, D, C, E, H then it continues by an arbitrary order ofG, B, F. (2 points) It does not matter which order you pick they lead to the same table.
A shortestAF path is A−C−F. (2 points)
2. Find a minimum spanning tree in the right graph by Kruskal's algorithm and determine its weight! Indicate the order of the decisions! Does the addition of an edge between vertices 2 and 3 with weight 6 decreases the weight of a minimum spanning tree?
6
9 3
7 4
3
2 1
2 3
6 2
4
5 5
8
6
1
2
3
4
5
6
7
8
Solution:
There are multiple minimum spanning trees. A minimum spanning tree worth 4 points.
The script of what have happened during the run of Kruskal worth 2 points. The weight of a minimum spanning tree is 24. (2 points) No the addition of{2,3}with weight 6 does not decreases the weight of a minimum spanning tree (1 point). Since the biggest weight was 6 in the original spanning tree if we run Kruskal's algorithm in the obtained graph it can nd the same minimum spanning tree if we put the new edge at the last possible place in the ordering of the edges (after all the edges whose weight is 6). (1 point) Of course a run of Kruskal's algorithm on the new graph also worth the 1 point.
Note that however it is true that each minimum spanning tree can be found by the run of Kruskal's algortihm I have not stated that during the lectures. However this is not needed for the solution.
3. Show that(3n2+ 4n+ 2)·(3n3+ 2n2+ 3n)∈O(n5). Is this function in O(n6logn)? Solution: We are checking the denition of the big O notation, so we show that there is a positive constant cand a numberN, such that (3n2+ 4n+ 2)·(3n3+ 2n2+ 3n)≤cn5 for all n ≥N. (1 point)
(3n2+ 4n+ 2)≤9n2 if n ≥1. (1 point) (3n3+ 2n2+ 3n)≤8n3 if n ≥1 (1 point)
Therefore(3n2+ 4n+ 2)·(3n3+ 2n2+ 3n)≤9n2·8n3 = 72n5 if n≥1 (2 points)
So if we choose c= 72, N = 1 then the denition of theO notation is satised (2 points) n5 ≤ n6logkn if n ≥ k (1 point) so c = 72, N = max(k,1) is good to show that the function is in O(n6logkn). (2 points)
4. Let COLORED HAMILTONIAN CYCLE be the following decision problem:
Input: A graph G and a coloring of its edges with two colors: red and blue (an edge is either red or blue).
Question: Does G contain a monochromatic (containing only blue edges or containing only red edges) Hamiltonian cycle?
(a) Show that COLORED HAMILTONIAN CYCLE is in NP!
(b) Give a HAMILTONIAN (CYCLE) ≺ COLORED HAMILTONIAN CYCLE Karp reduction!
Solution:
If the answer is yes, then a witness is a list (an ordering) of the vertices which correspond to a monochromatic Hamiltoninan cycle. (1 point) The size of the witness is polynomial in the size of the input. (1 point) The verication algorithm veries the correctness of the withess:
(a) The list contains each vertex exactly once and nothing else. (1point)
(b) Two vertices which are adjacent in the list are adjacent in the graph. (1point) (c) The vertices which are correspond to the rst element and the last element of the
list are adjacent in the graph. (1 point)
(d) All the edges which guarantee the adjacencies which we have checked have the same color. (1 point)
All of these can be checked in polynomial time, therefore this problem is in NP. (1 point) The Karp reduction:
Let G be an input of tha HAMILTONIAN CYCLE problem. Color all of its edges with the same color, and let this colored graph be the input of COLORED HAMILTONIAN CYCLE. (1 point)
Clearly Ghas a Hamiltonian cycle if and only if this colored graph has a monochromatic Hamiltonian cycle. (1 point)
The transformation can be calculated in polynomial time (we assign the same color for all the edges), so this is a Karp-reduction (1 point).
5. Let MINIMUM SPANNING TREE be the following decision problem: Input: GraphG, a weight function over its edge set (w:E(G)→Z) and a number k. Question: Does the graph Ghave a spanning tree of weight at most k?
Assume that P 6=N P. Under this assumption, do the following Karp reductions exist?
(a) PARTITION ≺ MINIMUM SPANNING TREE?
(b) MINIMUM SPANNING TREE ≺ 3-SAT?
Solution:
MINIMUM SPANNING TREE is in P because Kruskal is a polynomial time algo- rithm which nds a minimum spanning tree and then we can compare its weight with the given k in polynomial time. (2 point)
P ⊆N P, therefore MINIMUM SPANNING TREE is in NP. (1 point) PARTITION is NP-complete (1 point)
Therefore if PARTITION ≺ MINIMUM SPANNING TREE exists that means that MINIMUM SPANNING TREE is also NP-complete (1 point).
This mean that there is a Karp reduction from each problem contained in NP to MINIMUM SPANNING TREE. (1 point).
Because we can solve MINIMUM SPANNING TREE in polynomial time this would imply that we can solve all problems contained inN P in polynomial time (1 point).
This means that P=NP, so this Karp-reduction does not exist under the assumption (1 point).
3-SAT is NP-complete (1 point) therefore MINIMUM SPANNING TREE≺ 3-SAT exists. (1 point)