
CS473ug Head Banging Session #5 2/28/06 - 3/02/06
1. Rumor Mill
The Gossip Posse has a new rumor and wants to spread it as quickly as possible. Each member of the
Gossip Posse (except for the Big Bad Leader) is a lackey for one other member of the posse. So the
lackey hierarchy can be described as a tree, rooted at the Big Bad Leader, in which each member v
(except the Big Bad Leader), has a parent node u, for whom he or she is a lackey. To spread a rumor,
the Big Bad Leader calls each one of her lackeys. As soon as a member of the posse hears the rumor,
he must notify each of his lackeys. We can picture this process as being divided into rounds. In one
round, each member who has already heard the rumor calls one of his or her lackeys. The number of
rounds it takes for everyone to hear the rumor depends on the sequence in which each person calls his
or her lackeys.
Give an efficient algorithm that determines the minimum number of rounds needed for everyone in
the posse to be notified, and outputs a sequence of phone calls that achieve the minimum number of
rounds.
2. Making Change
Often a chashier wants to give change to a customer. Unless the customer requests otherwise, the
cashier wants to use the fewest number of bills. In a more general setting, say that the cashier
has the denominations {a1, a2,...,ak}, with ai< ai+1; he has an unlimited supply of bills of each
denomination.
(a) A greedy algorithm to solve this problem is to recursively choose the largest bill that is not more
than the amount of change we want to make. Construct an example where the greedy algorithm
does not give an optimal solution.
(b) Give an efficient algorithm to construct the optimal solution. (Think dynamic programming.)
(c) (Optional) The denominations of United States currency are $1, $2, $5, $10, $20, $50 and $100.
Does the greedy algorithm work for this set of denominations?
3. Gettin’ a goo d G.P.A
Suppose it’s nearing the end of the semester and you’re taking ncourses, each with a final project
that still has to be done. Each pro ject will be graded on the following scale: It will be assigned an
integer number on a scale of 1 to g > 1, higher numbers being better grades. Your goal, of course is to
maximize your average grade on the npro jects.
You have a total of H > n hours in which to work on the nprojects cumulatively, and you want to
decide how to divide up this time. For simplicity, assume His a positive integer, and you’ll spend an
integer number of hours on each project. To figure out how best to divide up your time, you’ve come
up with a set of functions {fi:i= 1,2,...,n}(rough estimates of course for each of your ncourses; if
you spend h≤Hhours on the pro ject for course i, you’ll get a grade of fi(h). (You may assume that
the functions fiare nondecreasing: if h < h′, then fi(h)≤fi(h′).)
So the problem is: Given the functions {fi}, decide how many hours to spend on each project (in integer
values only) so that your average grade, as computed according to the fi, is as large as possible. In
order to be efficient, the running time of your algorithm should be polynomial in n,g, and H.
1