Greedy Algorithms-Complexity of Algorithms-Assignment, Exercises of Advanced Algorithms

This assignment was given by Manju Nripendra at West Bengal State University for Theory of Complexity and Algorithms course. It includes: Greedy, Algorithms, Fractional, Knapsack, Problem, Interval, Scheduling, Art, Gallery, Guarding

Typology: Exercises

2011/2012

Uploaded on 07/17/2012

padmaghira
padmaghira 🇮🇳

3.2

(5)

53 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Greedy algorithms
1. Consider the set of items S={a, b, c, d, e, f, g, h}where the items have
the following (benefit,weight) values:
a(14,3)
b(5,1)
c(10,6)
d(12,4)
e(8,2)
f(10,4)
g(16,8)
h(9,9)
Solve the Fractional Knapsack Problem for this set of items, where the
maximum total allowed weight is Wmax = 15.
2. Let T={(1,3),(2,4),(3,5),(2,7),(4,6),(5,6),(3,7),(5,8),(6,10),(7,9),(8,10)}
denote the (start,finish) times for a collection of 11 tasks.
(a) Solve the Interval Scheduling Problem for this collection of tasks
(i.e. find the maximum number of tasks that can be scheduled on
a single machine, and give a set of compatible tasks that achieves
this maximum).
(b) Solve the Task Scheduling Problem for this collection of tasks
(i.e. find the minimum number of machines required to complete
all tasks, and give a schedule for doing so).
3. Describe an efficient greedy algorithm for making change for a specified
value using a minimum number of coins, assuming that there are four
denominations of currency of coins with values 25,10,5,1 (American
quarters, dimes, nickels, and pennies, respectively).
Argue why your algorithm is correct.
4. Give an example set of coins (i.e. specify their values) so that a greedy
change making algorithm will not always use the minimum number of
coins. Illustrate this by showing a value for which a greedy algorithm
like that in the above question doesn’t give the minimum number of
coins.
(Assume that the smallest denomination of coins in your set has value
1, so that a solution always exists.)
5. In the art gallery guarding problem we are given a line Lthat
represents a long (straight) hallway in an art gallery. We are also given
a set X={x1, x2, . . . , xn}of real numbers that represent locations
1
docsity.com
pf2

Partial preview of the text

Download Greedy Algorithms-Complexity of Algorithms-Assignment and more Exercises Advanced Algorithms in PDF only on Docsity!

Greedy algorithms

  1. Consider the set of items S = {a, b, c, d, e, f, g, h} where the items have the following (benefit, weight) values:

a (14, 3) b (5, 1) c (10, 6) d (12, 4) e (8, 2) f (10, 4) g (16, 8) h (9, 9)

Solve the Fractional Knapsack Problem for this set of items, where the maximum total allowed weight is Wmax = 15.

  1. Let T = {(1, 3), (2, 4), (3, 5), (2, 7), (4, 6), (5, 6), (3, 7), (5, 8), (6, 10), (7, 9), (8, 10)} denote the (start, finish) times for a collection of 11 tasks.

(a) Solve the Interval Scheduling Problem for this collection of tasks (i.e. find the maximum number of tasks that can be scheduled on a single machine, and give a set of compatible tasks that achieves this maximum). (b) Solve the Task Scheduling Problem for this collection of tasks (i.e. find the minimum number of machines required to complete all tasks, and give a schedule for doing so).

  1. Describe an efficient greedy algorithm for making change for a specified value using a minimum number of coins, assuming that there are four denominations of currency of coins with values 25, 10 , 5 , 1 (American quarters, dimes, nickels, and pennies, respectively). Argue why your algorithm is correct.
  2. Give an example set of coins (i.e. specify their values) so that a greedy change making algorithm will not always use the minimum number of coins. Illustrate this by showing a value for which a greedy algorithm like that in the above question doesn’t give the minimum number of coins. (Assume that the smallest denomination of coins in your set has value 1, so that a solution always exists.)
  3. In the art gallery guarding problem we are given a line L that represents a long (straight) hallway in an art gallery. We are also given a set X = {x 1 , x 2 ,... , xn} of real numbers that represent locations

docsity.com

where paintings are hung in the hallway. Suppose that a single guard can protect all the paintings within distance at most 1 of his or her position (on both sides).

Design an algorithm for finding a placement of the guards that uses the minimum number of guards to guard all the paintings with positions in X.

docsity.com