Docsity

Algorithm Design and Analysis: Problem Set 7 Solutions - Prof. Charles U. Martel, Assignments of Computer Science

Toggle sidebar
bg1
ECS 122A: Algorithm Design and Analysis Handout ??
UC Davis — Charles Martel March 3, 2009
Problem Set 7—Due Tues, March 10 3:10PM
(25) Problem 1. Use network flows to find an efficient solution for the following problem:
a) In a computer network there are pprocessors P1, P2, .., Pp, and ccommunication lines
C1, C2, ..., Cc(with c > p. Each processor ihas the ability to test tilines per day and there
is a list Liwhich contains the communication lines that processor iis able to test. Subject
to these constraints we would like to be able to test all the communication lines every day.
A testing schedule determines for each processor the lines it should test. Give an efficient
algorithm to find a testing schedule or determine that no schedule can test all lines in a single
day. Give the run time of your algorithm in terms of pand c.
b) Same as a) but find the minimum number of days to test all lines (and a schedule that
achieves it).
(25) Problem 2.
Suppose we are given a directed graph G;
a) We want to find 3 edge disjoint paths from a designated starting vertex uto a specific
destination vertex d(or determine that no such paths exist). Describe an efficient algorithm
to find the paths and give the running time of your solution.
b) Now suppose we have three different destinations d1, d2andd3. We want to find 3 paths
from our start vertex u, one to each of the destinations and we want these 3 paths to be edge
disjoint.Describe an efficient algorithm to find the paths and give the running time of your
solution.
(25) Problem 3 For the input string: BABAACAABAACACAABAACCBABAAC
(a) Give a huffman code for this string (describe both your tree and the actual binary
encoding of the above string).
(b) Give the ”high-level” Lempel-Ziv encoding of the above string where each match of
length 3 or longer is represented by a length, pointer pair, and otherwise by the actual input
character.
(c) Now give the actual bit string representation for the encoding of part b) that would be
produced by encoding literals, lengths and pointers using two huffman trees. Again give the
huffman trees used followed by the encoding.

Partial preview of the text

Download Algorithm Design and Analysis: Problem Set 7 Solutions - Prof. Charles U. Martel and more Assignments Computer Science in PDF only on Docsity!

ECS 122A: Algorithm Design and Analysis Handout ?? UC Davis — Charles Martel March 3, 2009

Problem Set 7—Due Tues, March 10 3:10PM

(25) Problem 1. Use network flows to find an efficient solution for the following problem:

a) In a computer network there are p processors P 1 , P 2 , .., Pp, and c communication lines C 1 , C 2 , ..., Cc (with c > p. Each processor i has the ability to test ti lines per day and there is a list Li which contains the communication lines that processor i is able to test. Subject to these constraints we would like to be able to test all the communication lines every day. A testing schedule determines for each processor the lines it should test. Give an efficient algorithm to find a testing schedule or determine that no schedule can test all lines in a single day. Give the run time of your algorithm in terms of p and c. b) Same as a) but find the minimum number of days to test all lines (and a schedule that achieves it).

(25) Problem 2.

Suppose we are given a directed graph G; a) We want to find 3 edge disjoint paths from a designated starting vertex u to a specific destination vertex d (or determine that no such paths exist). Describe an efficient algorithm to find the paths and give the running time of your solution. b) Now suppose we have three different destinations d 1 , d 2 andd 3. We want to find 3 paths from our start vertex u, one to each of the destinations and we want these 3 paths to be edge disjoint.Describe an efficient algorithm to find the paths and give the running time of your solution.

(25) Problem 3 For the input string: BABAACAABAACACAABAACCBABAAC

(a) Give a huffman code for this string (describe both your tree and the actual binary encoding of the above string). (b) Give the ”high-level” Lempel-Ziv encoding of the above string where each match of length 3 or longer is represented by a length, pointer pair, and otherwise by the actual input character. (c) Now give the actual bit string representation for the encoding of part b) that would be produced by encoding literals, lengths and pointers using two huffman trees. Again give the huffman trees used followed by the encoding.