Docsity

Problems on Algorithm Design and Analysis - Assignment 5 | ECS 122A, Assignments of Computer Science

Toggle sidebar
bg1
ECS 122A: Algorithm Design and Analysis Handout 5
UC Davis — Charles Martel Due Wednesday, May 28, 2008, 4:00 PM
Problem Set 5
Homework Info Homeworks are due by 4:00 PM on the due date. They are to be turned in at
the marked box in K
¯emper Hall, room 2131 (right side). No late homeworks will be accepted.
Much of what one learns in this course comes from trying to solve the homework problems, so work hard on
them. Doing a conscientious job on the homeworks is the best preparation for the exams. We hope that you
will ultimately solve the majority of the problems, but don’t be surprised if some of them stump you; some
of the problems may be quite challenging.
Your solutions should be terse, correct, and legible. Understandability of the solution is as necessary as
correctness. Expect to lose points if you provide a ”correct” solution with a not-so-good writeup. As with
an English paper, you can’t expect to turn in a first draft: it takes refinement to describe something well.
Typeset solutions are always appreciated.
If you can’t solve a problem, briefly indicate what you’ve tried and where the difficulty lies. Don’t try to
pull one over on us.
If you think a problem was misgraded, please see the grader first. (The TA will be the grader for the
homework).
1 Graph Colorability, KT 8.7 (30)
A graph Gis said to be k-colorable if its vertices can be colored with kdifferent colors such that
no two adjacent vertices share the same color.
•Describe a polynomial-time algorithm to solve the graph-2-colorability problem.
•Show that graph-4-colorability problem is NP-Complete. Hint: graph-3-colorability
is NP-Complete (KT 8.7).
2 Input Size (10)
Earlier in the course, we saw a dynamic programming algorithm for the Knapsack problem: Given
nitems, each with a weight wiand a value vi, and a weight bound W, what is the maximum valued
set of items whose weight does not exceed W? What was the running time for this dynammic
programming algorithm, and is it polynomial in the input size? Why or why not?
3 Independent Set (15)
Given a graph Gand an integer kwhere kis a constant, and passed as an input parameter, show
a polynomial-time algorithm for the Independent Set problem.
pf2

Partial preview of the text

Download Problems on Algorithm Design and Analysis - Assignment 5 | ECS 122A and more Assignments Computer Science in PDF only on Docsity!

ECS 122A: Algorithm Design and Analysis Handout 5 UC Davis — Charles Martel Due Wednesday, May 28, 2008, 4:00 PM

Problem Set 5

Homework Info Homeworks are due by 4:00 PM on the due date. They are to be turned in at

the marked box in K ¯ emper Hall, room 2131 (right side). No late homeworks will be accepted.

Much of what one learns in this course comes from trying to solve the homework problems, so work hard on them. Doing a conscientious job on the homeworks is the best preparation for the exams. We hope that you will ultimately solve the majority of the problems, but don’t be surprised if some of them stump you; some of the problems may be quite challenging.

Your solutions should be terse, correct, and legible. Understandability of the solution is as necessary as correctness. Expect to lose points if you provide a ”correct” solution with a not-so-good writeup. As with an English paper, you can’t expect to turn in a first draft: it takes refinement to describe something well. Typeset solutions are always appreciated.

If you can’t solve a problem, briefly indicate what you’ve tried and where the difficulty lies. Don’t try to pull one over on us.

If you think a problem was misgraded, please see the grader first. (The TA will be the grader for the homework).

1 Graph Colorability, KT 8.7 (30)

A graph G is said to be k-colorable if its vertices can be colored with k different colors such that no two adjacent vertices share the same color.

  • Describe a polynomial-time algorithm to solve the graph-2-colorability problem.
  • Show that graph-4-colorability problem is NP-Complete. Hint: graph-3-colorability is NP-Complete (KT 8.7).

2 Input Size (10)

Earlier in the course, we saw a dynamic programming algorithm for the Knapsack problem: Given n items, each with a weight wi and a value vi, and a weight bound W , what is the maximum valued set of items whose weight does not exceed W? What was the running time for this dynammic programming algorithm, and is it polynomial in the input size? Why or why not?

3 Independent Set (15)

Given a graph G and an integer k where k is a constant, and passed as an input parameter, show a polynomial-time algorithm for the Independent Set problem.

2 ECS 122A Handout 5: Problem Set 5

4 KT, Chap 8, problem 2, pg. 505 (20)

5 Gzip (15)

For the input string: ACABAACAABAACACAABAACBA

  1. Give the huffman code for this string (describe both your tree and the actual binary encoding of the above string).
  2. Give the “high-level” Lempel-Ziv encoding of the above string where each match length of 3 or longer is represented by a length,
  3. Give the huffman trees for the LZ encoding of part 2 (the tree for the literals and lengths, and the tree for the position). Use these huffman trees to produce the final gzip encoding of the string.

6 Vertex Cover (20)

Suppose we have a procedure D that solves the decision version of Vertex Cover (VC): given a graph G and an integer k is there a VC of size k? (note: we make no claims here as to how fast D runs, just that it works).

  1. Show how to solve the optimization version of VC (given a graph G find k∗, the smallest size of a vertex cover in G). using a polynomial calls to the decision routine D (using inputs of size polynomial in G, the original input graph).
  2. Now show how, for an input graph G, to find the actual vertex cover C that is of size k∗, again using a polynomial calls to the decision routine D (using inputs of size polynomial in G, the original input graph).