Daa2020 Tutorial 04
Daa2020 Tutorial 04
That is, the maximal independent sets of (S, I 0 ) are just the complements of the
maximal independent sets of (S, I).
5. Show how to transform the weight function of a weighted matroid problem, where the
desired optimal solution is a minimum-weight maximal independent subset, to make
it a standard weighted-matroid problem. Argue carefully that your transformation
is correct.
6. (a) Solve the following instance of the 0/1 Knapsack Problem using the Dynamic
Programming algorithm:
(Ii )5i=1 = (I1 , I2 , I3 , I4 , I5 ),
(wi )5i=1 = (1, 2, 3, 4, 5),
(pi )5i=1 = (5, 4, 3, 2, 1),
W = 8.
(b) Suppose that in a 0/1 Knapsack Problem, the order of the items when sorted
by increasing weight is the same as their order when sorted by decreasing value
(for example, as given in problem 6(a)). Give an efficient algorithm (having
time complexity O(n log n)) to find an optimal solution to this variant of the
knapsack problem, and argue that your algorithm is correct.
7. There is a tower of floors, and an egg dropper with ideal eggs. The physical prop-
erties of the ideal egg is such that it will shatter if it is dropped from floor n∗ or
above, and will have no damage whatsoever if it is dropped from floor n∗ − 1 or be-
low. The problem is to find a strategy such that the egg dropper can determine the
floor n∗ in as few egg drops as possible. Design an efficient Dynamic Programming
algorithm for solving this problem, and find its complexity. Show the working of
your algorithm for n = 10 floors, and m = 2 eggs.
8. Let G = (V, E) be an undirected graph with n nodes. Recall that a subset of the
nodes is called an independent set if no two of them are joined by an edge. Finding
large independent sets is difficult in general; but here we will see that it can be done
efficiently if the graph is “simple” enough. Call a graph G = (V, E) a path if its
nodes can be written as v1 , v2 , . . . , vn , with an edge between vi and vj if and only if
the numbers i and j differ by exactly 1. With each node vi , we associate a positive
integer weight wi . Consider, for example, the five-node path drawn in Figure 1.
The weights are the numbers drawn inside the nodes. The goal in this question is
to solve the following problem:
Find an independent set in a path G whose total weight is as large as possible.
Design an efficient Dynamic Programming algorithm that takes an n-node path G
with weights and returns an independent set of maximum total weight. The running
time of your algorithm should be polynomial in n, independent of the values of
the weights. Give a formal correctness proof for your algorithm. Find the time
complexity of your algorithm and show its working on the given example (Figure
1).
Figure 1: A path with weights on the nodes. The maximum weight of an independent set is 14.
9. Suppose you are managing the construction of billboards on a Highway that runs for
M miles. The possible sites for billboards are given by numbers { x1 , x2 , . . . , xn },
each in the interval [0, M ]. If you place a billboard at location xi , you receive a
revenue of ri > 0. Regulations imposed by the Highway Department require that no
two of the billboards be within less than or equal to 5 miles of each other. You have
to place billboards at a subset of the sites so as to maximize your total revenue,
subject to this restriction.
Example: Suppose M = 20, n = 4,
{x1 , x2 , x3 , x4 } = {6, 7, 12, 14}, and
{r1 , r2 , r3 , r4 } = {5, 6, 5, 1}.
Then the optimal solution would be to place billboards at x1 and x3 , for a total
revenue of 10. Design an efficient Dynamic Programming algorithm that takes an
instance of this problem as input and returns the maximum total revenue that can
be obtained from any valid subset of sites. The running time of the algorithm should
be polynomial in n. Show the working of your algorithm on the given example.