CS 1510 Midterm 3 - NP-Completeness and Optimization Problems - Prof. Kirk R. Pruhs, Exams of Computer Science

The cs 1510 midterm 3 exam from fall 2003. The exam covers topics such as np-completeness, the 3clique problem, the vertex cover problem, and the bahncard problem. Students are expected to demonstrate their understanding of these concepts by providing solutions to the given problems.

Typology: Exams

Pre 2010

Uploaded on 09/02/2009

koofers-user-p4m
koofers-user-p4m šŸ‡ŗšŸ‡ø

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 1510 Midterm 3
Fall 2003
1. (20 points) Consider the following 3Clique problem:
INPUT: A undirected graph Gand an integer k.
OUTPUT: 1 if Ghas three vertex disjoint cliques of size k, and 0 otherwise.
Show that this problem is N P -hard. Use the fact that the clique problem in N P -complete.
The input to the clique problem is an undirected graph Hand an integer j. The output
should be 1 if Hcontains a clique of size jand 0 otherwise. Note that a clique is a mutually
adjacent collection of vertices. Three cliques are disjoint if no vertex is in more than one
clique.
2. (20 points) Show that the Vertex Cover Problem is self-reducible. The decision problem is
to take a graph Gand an integer kand decide if Ghas a vertex cover of size kor not. The
optimization problem takes a graph G, and returns a smallest vertex cover in G. So you must
show that if the decision problem has a polynomial time algorithm then the optimization
problem also has a polynomial time algorithm. Recall that a vertex cover is a collection Sof
vertices with the property that every edge is incident to a vertex in S.
3. (20 points) Consider the following Bahncard problem where the input is a collection of n
train trips within Germany. For the ith trip Tiyou are given the date diof that trip, and the
non-discounted fare fifor that trip. For simplicity we will assume that dates are nonnegative
integers. The German railway system sells a Bahncard for YEuros that entitles you to a
50% fare reduction on all train travel within Germany within Adays of purchase. You can
apply at most one Bahncard discount to a particular trip. The problem is to determine the
least you can spend on your travel.
In this paragraph we give an example. Assume that Y= 50, A= 100. Further assume,
d1= 1, f1= 20 Euros, d2= 40, f2= 200 Euros, d3= 80, f3= 200 Euros, d4= 120, f4= 100
Euros, d5= 200, f5= 200 Euros, and d6= 400, and f6= 600 Euros. Then you might buy a
Bahncard on day 40, and day 400. This results in a total cost of
20 + 50 + (.5) (200) + (.5)(200) + (.5 )(100) + 200 + 50 + (.5)(600)
Give an O(n2) time algorithm for problem. Significant partial credit will be given for any
polynomial time algorithm.
1

Partial preview of the text

Download CS 1510 Midterm 3 - NP-Completeness and Optimization Problems - Prof. Kirk R. Pruhs and more Exams Computer Science in PDF only on Docsity!

CS 1510 Midterm 3 Fall 2003

  1. (20 points) Consider the following 3Clique problem:

INPUT: A undirected graph G and an integer k. OUTPUT: 1 if G has three vertex disjoint cliques of size k, and 0 otherwise. Show that this problem is N P -hard. Use the fact that the clique problem in N P -complete. The input to the clique problem is an undirected graph H and an integer j. The output should be 1 if H contains a clique of size j and 0 otherwise. Note that a clique is a mutually adjacent collection of vertices. Three cliques are disjoint if no vertex is in more than one clique.

  1. (20 points) Show that the Vertex Cover Problem is self-reducible. The decision problem is to take a graph G and an integer k and decide if G has a vertex cover of size k or not. The optimization problem takes a graph G, and returns a smallest vertex cover in G. So you must show that if the decision problem has a polynomial time algorithm then the optimization problem also has a polynomial time algorithm. Recall that a vertex cover is a collection S of vertices with the property that every edge is incident to a vertex in S.
  2. (20 points) Consider the following Bahncard problem where the input is a collection of n train trips within Germany. For the ith trip Ti you are given the date di of that trip, and the non-discounted fare fi for that trip. For simplicity we will assume that dates are nonnegative integers. The German railway system sells a Bahncard for Y Euros that entitles you to a 50% fare reduction on all train travel within Germany within A days of purchase. You can apply at most one Bahncard discount to a particular trip. The problem is to determine the least you can spend on your travel. In this paragraph we give an example. Assume that Y = 50, A = 100. Further assume, d 1 = 1, f 1 = 20 Euros, d 2 = 40, f 2 = 200 Euros, d 3 = 80, f 3 = 200 Euros, d 4 = 120, f 4 = 100 Euros, d 5 = 200, f 5 = 200 Euros, and d 6 = 400, and f 6 = 600 Euros. Then you might buy a Bahncard on day 40, and day 400. This results in a total cost of

20 + 50 + (.5)(200) + (.5)(200) + (.5)(100) + 200 + 50 + (.5)(600)

Give an O(n^2 ) time algorithm for problem. Significant partial credit will be given for any polynomial time algorithm.