Tutorial #8 Problems

This problem is based on 8.4 from the Kleinberg and Tardos textbook.

Suppose you’re consulting for a group that manages a high-performance real-time system in which asynchronous processes make use of shared resources. Thus, the system has a set of n processes and a set of m resources. Each process specifies a set of resources that it requests to use. Each resource might be requested by many processes at once, but it can only be used by a single process at a time.

Your job is to allocate resources to processes that request them. If a process is allocated all the resources it requests, then it is active; otherwise, it is blocked. You want to perform the allocation so that as many processes as possible are active.

Thus, we phrase the Resource Reservation Problem (RR) as follows: Given a set of processes and resources, the set of requested resources for each process, and a number k, is it possible to allocate resources to processes so that at least k processes will be active?

1. For this part and the next part only, assume you do have a polynomial-time algorithm for RR. Give a polynomial-time algorithm to determine the largest k for which you can allocate resources to processes so that at least k processes will be active.
2. Still assuming you have a polynomial-time algorithm for RR, give a polynomial-time algorithm to determine a maximum-size set of processes that can be simultaneously active. (The specific processes, not just how many there are.)
3. Now stop assuming you have a polynomial-time algorithm for RR, and consider the following list of problems. For each problem either give a polynomial-time algorithm or prove that the problem is NP-complete. (In the former case, your “algorithm” may be a reduction to another problem that you know can be solved in polynomial time. Hint: One of these can be solved in polynomial time by reduction to the “maximum matching problem”, which can be solved in polynomial time.)
1. The general Resource Reservation Problem defined above.
2. The special case of the problem when k = 2.
3. The special case of the problem when k = 10.
4. The special case of the problem when there are two types of resources—say, robotic dogs and robotic cats—and each process requires exactly one resource of each type. (In other words, each process requires one specific robotic dog and one specific robotic cat.)
5. The special case of the problem when each resource is requested by at most two processes.

Slides #15: What’s in a Reduction? (A Problem By Any Other Name Would.. um.. Be Asymptotically Sweet?)

Here’s PDF of the 2015/03/20 notes.

• Section 8.1

• Section 8.1

I’d like you to focus your reading on: (1) how their definition of reductions differs from ours (and also how the limited version they’ll be using in “essentially all [their] reductions” (p 458) differs from ours) and (2) their “First Reduction”.

We’ll go back through and read it once more for all the details.

(As always, also read the chapter intro!)

Assignment #6

PDF document: Assignment #6

Due Monday 2015/03/23 at 5PM BUT NOT IN THE BOX. Submit electronically via handin instead. (See the PDF document.)

• Read the academic conduct guidelines or expect horrendous consequences for you.
• Please work with a partner; you’ll learn more, and we’ll spend less time on marking and more on making the course awesome.

Tutorial #7 Problems

Provide a recurrence relation for the quantity described in each of the following problems. For each one, also indicate either a memoized or dynamic programming approach to solving the recurrence and analyse its efficiency. (Do DP at least once. Remember that it’s the harder one because you must order the subproblems “manually” and so worth a bit of extra practice.)

1. Let G = (V, E) be an undirected graph with n nodes. 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 it can be done efficiently if the graph is simple enough.

Let us call the graph G a path if its nodes can be written as v0, v1, …, vn-1 with an edge between vi and vj if and only if the numbers i and j are consecutive. With each node vi we associate a positive integer weight wi. For example, in the following path, the weights are the numbers drawn inside the nodes.

Define recurrence relations for

• With[i]: the maximum sum we can obtain using non-consecutive elements from v0, …, vi, including the element vi in the sum.
• Without[i]: the maximum sum we can obtain using non-consecutive elements from v0, …, vi, without including the element vi in the sum.
2. There are many sunny Spring days in Vancouver. Unfortunately, this year, it is raining on the day of the CSSS (CS student society) boat cruise and dinner. The CSSS president decides to rebook the cruise for another day, and needs to contact everybody who has made reservations. Luckily, every student made his/her reservation by talking to another student who had already made his/hers. That is, the students who have reservations for the cruise form a tree, whose root is the CSSS president!

To notify everyone of the postponement, the CSSS president first calls each of the students who bought their tickets directly from him/her, one at a time (his/her “children”). As soon as one of these students has been notified, he/she can then notify all of his/her “children”.

We can picture this process as being divided into rounds. In one round, each person who has already learned of the postponement can call one of his/her children. The number of rounds it takes for everyone to be notified depends on the sequence in which each person makes their phone calls. For instance, in the following figure, it will take only two rounds if A calls B first, but three rounds if A starts by calling D (note that A can not call C directly).

Write a recurrence relation for R(N), the minimum number of rounds needed to inform all descendants of a node N.

3. As some of you know well, and others of you may be interested to learn, a number of languages (including Chinese and Janapese) are written without spaces between the words. Consequently, software that works with text written in these languages must address the word segmentation problem: inferring likely boundaries between consecutive words in the text. If English were written without spaces, the analogous problem would consist of taking a string like “meetaeight” and deciding that the best segmentation is “meet at eight” (and not “me et at eight”, or “meet ate ight”, or any of the huge number of even less plausible alternatives). How could we automate this process?A simple approach that is at least reasonably effective is to find a segmentation that simply maximizes the cumulative “quality” of its individual constituent words. Thus, suppose you are given a black box that for any string of letters x = x0, x1, …, xk will return a number Q(x). This number can be either positive or negative; larger numbers correspond to more plausible English words. So Q(me) would be positive, while Q(ght) would be negative.

Given a long string of letters y = y0, y1, …, yn-1, a segmentation of y is a partition of its letters into contiguous blocks of letters; each block corresponds to a word in the segmentation. The total quality of a segmentation is determined by adding up the qualities of each of its blocks. So we would get the right answer for the problem above provided that Q(meet) + Q(at) + Q(eight) was greater than the total quality of any other segmentation of the string.

Give a recurrence relation for TQ(i): the maximum total quality of any segmentation of the letters y0, y1, …, yi. Hint: look for the position of the first letter of the current “word”.