Unformatted text preview: uard can protect all the paintings within distance at most 1 of his or her
position (on both sides). Design an algorithm for ﬁnding a placement of guards
that uses the minimum number of guards to guard all the paintings with positions
in X .
C5.6 Design a divideandconquer algorithm for ﬁnding the minimum and the maximum element of n numbers using no more than 3n/2 comparisons.
C5.7 Given a set P of n teams in some sport, a roundrobin tournament is a collection
of games in which each team plays each other team exactly once. Design an
efﬁcient algorithm for constructing a roundrobin tournament assuming n is a
power of 2.
C5.8 Let a set of intervals S = {[a0 , b0 ], [a1 , b1 ], . . . , [an−1 , bn−1 ]} of the interval [0, 1]
be given, with 0 ≤ ai < bi ≤ 1, for i = 0, 1, . . . , n − 1. Suppose further that we
assign a height hi to each interval [ai , bi ] in S. The upper envelope of S is deﬁned
to be a list of pairs [(x0 , c0 ), (x1 , c1 ), (x2 , c2 ), . . . , (xm , cm ), (xm+1 , 0)], with x0 =
0 and xm+1 = 1, and ordered by xi values, such that, for each subinterval s =
[xi , xi+1 ] the height of the highest interval in S containing s is ci , for i = 0, 1, . . . , m.
Design an O(n log n)time algorithm for computing the upper envelope of S.
C5.9 How can we modify the dynamic programming algorithm from simply computing the best beneﬁt value for the 01 knapsack problem to computing the assignment that gives this beneﬁt?
C5.10 Suppose we are given a collection A = {a1 , a2 , . . . , an } of n positive integers that
add up to N . Design an O(nN )time algorithm for determining whether there is
a subset B ⊂ A, such that ∑ai ∈B ai = ∑ai ∈A−B ai . Chapter 5. Fundamental Techniques 284 C5.11 Let P be a convex polygon (Section 12.5.1). A triangulation of P is an addition
of diagonals connecting the vertices of P so that each interior face is a triangle.
The weight of a triangulation is the sum of the lengths of the diagonals. Assuming
that we can compute lengths and add and compare them in constant time, give an
efﬁcient algorithm for computing a minimumweight triangulation of P.
C5.12 A grammar G is a way of generating strings of “terminal” characters from a
nonterminal symbol S, by applying simple substitution rules, called productions.
If B → β is a production, then we can convert a string of the form αBγ into the
string αβγ. A grammar is in Chomsky normal form if every production is of the
form “A → BC” or “A → a,” where A, B, and C are nonterminal characters and a
is a terminal character. Design an O(n3 )time dynamic programming algorithm
for determining if string x = x0 x1 · · · xn−1 can be generated from start symbol S.
C5.13 Suppose we are given an nnode rooted tree T , such that each node v in T is given
a weight w(v). An independent set of T is a subset S of the nodes of T such that
no node in S is a child or parent of any other node in S. Design an efﬁcient
dynamic programming algorithm to ﬁnd the maximumweight independent set
of the nodes in T , where the weight of a set of nodes is simply the sum of the
weights of the nodes in that set. What is the running time of your algorithm? Projects
P5.1 Design and implement a big integer package supporting the four basic arithmetic
operations.
P5.2 Implement a system for efﬁciently solving knapsack problems. Your system
should work for either fractional or 01 knapsack problems. Perform an experimental analysis to test the efﬁciency of your system. Chapter Notes
The term “greedy algorithm” was coined by Edmonds [64] in 1971, although the concept
existed before then. For more information about the greedy method and the theory that
supports it, which is known as matroid theory, please see the book by Papadimitriou and
Steiglitz [164].
The divideandconquer technique is a part of the folklore of data structure and algorithm design. The master method for solving divideandconquer recurrences traces its
origins to a paper by Bentley, Haken, and Saxe [30]. The divideandconquer algorithm
for multiplying two large integers in O(n1.585) time is generally attributed to the Russians
Karatsuba and Ofman [111]. The asymptotically fastest known algorithm for multiplying
two ndigit numbers is an FFTbased algorithm by Sch¨ nhage and Strassen [181] that runs
o
in O(n log n log log n) time.
Dynamic programming was developed in the operations research community and formalized by Bellman [26]. The matrix chainproduct solution we described is due to Godbole [78]. The asymptotically fastest method is due to Hu and Shing [101, 102]. The dynamic programming algorithm for the knapsack problem is found in the book by Hu [100].
Hirchsberg [95] shows how to solve the longest common substring problem in the same
time given above, but with linear space (see also [56])....
View
Full
Document
This document was uploaded on 03/26/2014.
 Spring '14

Click to edit the document details