You are on page 1of 2

Introduction to Algorithms Problem Set 7

CS 4820 Fall 2017 Due 11:59pm Thursday, October 26

Your homework submissions need to be typeset (hand-drawn figures are OK). See the
course web page for suggestions on typing formulas. Your solution to each question needs to be
uploaded to CMS as a separate pdf file. To help enable more anonymous grading: do not write your
name on the homework (CMS will know it’s your submission). Collaboration is encouraged. Write
the netid of your collaborators on your solution. However, you need to write up solutions
separately! Remember that when a problem asks you to design an algorithm, you must
also prove the algorithm’s correctness and analyze its running time. The running time (or
expected running time) must be bounded by a polynomial function of the input size.

(1) (15 points) In this question you are helping scheduling shifts for nurses in a hospital for a period
of D days. There is a set of N nurses that you plan to make a schedule for. They asked you to assign
nurses to days that they will work on (they will divide up who will work what part of the day later, but
this will not be relevant for this exam problem). Each part asks you to give a polynomial time algorithm
to find a schedule that satisfies some constraints, if such a schedule exists. You should analyze your
algorithm’s running time, and prove its correctness.

a. (5 points) The basic constraints are as follows:

i. Nurses were asked which days they are available to work on. You were given these lists Li for
nurse i. Each nurse i should only work on a subset of days in Li
ii. Different nurses are required to work different total number of days during this period, depending
on their contracts. Nurse i should work ni days. All nurses are required to enter a long enough
list, that is, you may assume |Li | > ni .
iii. Days have different needs (e.g., days when a lot of surgeons are working need more nurses). Each
day d, we require rd nurses to be present.

b. (5 points) Assume that i ni ≥ d rd . After seeing a round of the schedule you produced, one of
P P

the nurses, nurse i, realizes that he/she made a mistake, and is now scheduled to work on a day (day
d), that should not have been on his/her list Li . Let L = i |Li | denote the sum of the length of all
P

the lists. Give an O(|D| + |N | + L) time algorithm that starts from a feasible schedule with this one
mistake (and all the constraints), and tests if there is a feasible schedule where nurse i doesn’t work
on day d.

c. (5 points) After seeing a round of your schedule, the hospital administration realizes that solutions
are too hard on some nurses, as they work too many days in a row (without violating the total of
ni day constraints). Assume that the planning period consist of a number of full weeks. Explain
how you can modify your solution for part (a.) adding the requirement that no nurse is allowed to
work more than 5 days in any week (any Sunday through Saturday period). You should analyze your
algorithm’s running time, and prove its correctness.

(2) (5 points) Your friends have written a very fast piece of maximum flow code based on repeatedly
finding augmenting paths as in Section 7.2. However, after you’ve looked at a bit of output from it, you
realize that it’s not always finding a flow of maximum value. The bug turns out to be pretty easy to
find; your friends hadn’t really gotten into the whole backward-edge thing when writing the code, and
so their implementation builds a variant of the residual graph that only includes the forward edges. In
other words, it searches for s-t paths in a graph G˜f consisting only of edges e for which f (e) < ce , and

1
it terminates when there is no augmenting path consisting entirely of such edges. We’ll call this the
“forward-edge-only” flow algorithm. (Note that we do not try to prescribe how this algorithm chooses
its forward-edge paths; it may choose them in any fashion it wants, provided that it only terminates
when no forward-edge path exists any more.)
It’s hard to convince your friends they need to re-implement the code; in addition to its blazing
speed, they claim in fact that it never looses much compared to the maximum flow. Concretely, they
claim that the resulting flow always has value at least half of the maximum possible. returns a flow
whose value is less than a fixed fraction of optimal. Do you believe this? To be precise the proposed
claim is as follows:

On every instance of the maximum flow problem, the forward-edge-only algorithm is guar-
anteed to find a flow of value at least 1/2 of the maximum flow value (regardless of how it
chooses its forward-edge paths).

Decide whether you think this statement is true or false, and either give a counter example or a proof
of the statement.

(3) (10 points) An induced matching in an undirected graph G is a set of edges,

M = {(u1 , v1 ), (u2 , v2 ), . . . , (uk , vk )}

such that:

1. M is a matching, i.e. no vertex belongs to more than one edge of M .

2. Apart from the edges of M , no other edge of G has both of its endpoints in the set
{u1 , . . . , uk , v1 , . . . , vk }.

In the Induced Matching Problem, the input is an undirected graph G = (V, E) and a positive
integer k, and the problem is to decide whether the graph G contains an induced matching of size at
least k. Prove that the Induced Matching Problem is at least as hard as the Independent Set
Problem.

You might also like