Docsity

CMSC 451 Homework: Energy Spanning Tree & Activity Scheduling (Spring 2004) - Prof. Aravin, Assignments of Computer Science

Toggle sidebar
bg1
CMSC 451: Homework 2, Spring 2004
Due at the beginning of class on February 24.
Warning: some of the problems require thought - do not wait until the last
day to start working on them!
If you cannot come up with algorithms that run in the required time, then
provide (correct) slower algorithms for partial credit. Write your answers using
pseudo-code in the same style as the textbook. These make the algorithm
description precise, and easy to read (as opposed to code in C or some other
language).
1. We are given an undirected graph G= (V, E) with a weight w(u, v) for
each edge (u, v); importantly, each given w(u, v) is non-negative. Define
a minimum spanning tree (MST) of Gas usual. In addition, define the
energy of each edge (u,v ) to be (w(u, v))2, i.e., the square of the weight
of the edge. Now define a minimum-energy spanning tree (MEST) of G
as a spanning tree, which minimizes the total energy of the edges used.
Present an efficient algorithm for finding a spanning tree that is both an
MST and an MEST; prove the correctness of your algorithm, and say what
its time-complexity is. (The minimum-energy version is useful in wireless
networking, as will be explained later.)
2. Consider the Activity Selection Problem from Section 16.1 of the textbook.
Consider the following proposed algorithm for this problem. Let the dif-
ference fi−sibe called the length of activity ai. The algorithm repeatedly
chooses an activity of smallest length, throws away all other activities that
overlap with this activity, and repeats this until no activities are left. You
can verify that the set of activities chosen by this greedy algorithm are
indeed mutually compatible. Show that this algorithm does not always
choose a maximum-sized subset of mutually compatible activities.
3. You are given a set S={a1, a2, . . . , an}of ntasks, where task aineeds
piunits of processing time to complete, once it has started. You want to
schedule these tasks on one computer; the computer can only process one
task at a time. Given a schedule, let cibe the completion time of task
ai: i.e., the time at which aicompletes processing. You wish to schedule
the tasks in order to minimize the total completion time of the tasks: i.e.,
you want to minimize Pn
i=1 ci. For example, suppose n= 2, p1= 3, and
p2= 5. If we schedule a1first and a2next, then c1= 3 and c2= 8.
Otherwise, if we schedule a2first and a1next, then c1= 8 and c2= 5.
Since 3 + 8 <8 + 5, the first schedule is the optimal schedule in this
example.
(a) Suggest an algorithm to minimize the total completion time. Each
task must run non-preemptively: i.e., once task aiis started, it must
run continuously for piunits of time. (Hint: Consider small exam-
ples with n= 2, n= 3 etc., to get a hint about how an optimal
schedule will look.)
1
pf2

Partial preview of the text

Download CMSC 451 Homework: Energy Spanning Tree & Activity Scheduling (Spring 2004) - Prof. Aravin and more Assignments Computer Science in PDF only on Docsity!

CMSC 451: Homework 2, Spring 2004

Due at the beginning of class on February 24.

Warning: some of the problems require thought - do not wait until the last day to start working on them! If you cannot come up with algorithms that run in the required time, then provide (correct) slower algorithms for partial credit. Write your answers using pseudo-code in the same style as the textbook. These make the algorithm description precise, and easy to read (as opposed to code in C or some other language).

  1. We are given an undirected graph G = (V, E) with a weight w(u, v) for each edge (u, v); importantly, each given w(u, v) is non-negative. Define a minimum spanning tree (MST) of G as usual. In addition, define the energy of each edge (u, v) to be (w(u, v))^2 , i.e., the square of the weight of the edge. Now define a minimum-energy spanning tree (MEST) of G as a spanning tree, which minimizes the total energy of the edges used. Present an efficient algorithm for finding a spanning tree that is both an MST and an MEST; prove the correctness of your algorithm, and say what its time-complexity is. (The minimum-energy version is useful in wireless networking, as will be explained later.)
  2. Consider the Activity Selection Problem from Section 16.1 of the textbook. Consider the following proposed algorithm for this problem. Let the dif- ference fi −si be called the length of activity ai. The algorithm repeatedly chooses an activity of smallest length, throws away all other activities that overlap with this activity, and repeats this until no activities are left. You can verify that the set of activities chosen by this greedy algorithm are indeed mutually compatible. Show that this algorithm does not always choose a maximum-sized subset of mutually compatible activities.
  3. You are given a set S = {a 1 , a 2 ,... , an} of n tasks, where task ai needs pi units of processing time to complete, once it has started. You want to schedule these tasks on one computer; the computer can only process one task at a time. Given a schedule, let ci be the completion time of task ai: i.e., the time at which ai completes processing. You wish to schedule the tasks in order to minimize the total completion time of the tasks: i.e., you want to minimize

∑n i=1 ci. For example, suppose^ n^ = 2,^ p^1 = 3, and p 2 = 5. If we schedule a 1 first and a 2 next, then c 1 = 3 and c 2 = 8. Otherwise, if we schedule a 2 first and a 1 next, then c 1 = 8 and c 2 = 5. Since 3 + 8 < 8 + 5, the first schedule is the optimal schedule in this example. (a) Suggest an algorithm to minimize the total completion time. Each task must run non-preemptively: i.e., once task ai is started, it must run continuously for pi units of time. (Hint: Consider small exam- ples with n = 2, n = 3 etc., to get a hint about how an optimal schedule will look.)

(b) Prove that your algorithm indeed minimizes the total completion time.

  1. (Only for graduate students) We are given a connected undirected graph G = (V, E) with a weight w(u, v) given for each edge (u, v), such that all the given weights are distinct (i.e., no two are the same). Consider the following algorithm for finding a minimum spanning tree (MST) in G. Initialize a graph H to be the graph G (as we proceed, we will delete some edges from H, as seen below). We first sort the edges in decreasing order of weight, and consider the edges in this decreasing-weight order. When considering an edge (u, v), we test if deleting this edge will still keep the graph H connected; if so, we delete this edge from H. (Note that the test performed, and the deletion, is on H, and not on G.) After considering all the edges, we output the edges in the remaining graph H, as an MST.

(a) Prove that the final set of edges that is output, is indeed a spanning tree. (b) Is the output indeed an MST? Justify your answer.