t6ans - CS3230 Tutorial 6 1. Consider the greedy algorithm...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS3230 Tutorial 6 1. Consider the greedy algorithm for coin-change problem. Suppose the coin denominations are d 1 > d 2 > . . . > d n = 1. Suppose that d i +1 is a factor of d i , for 1 i < n . Then, show that the greedy algorithm is optimal. Ans: (i) Due to the constraint given in the problem, in the optimal algorithm, one has < d i /d i +1 coins of denomination d i +1 . (ii) Fact (i) implies that sum of values of coins of denomination d j , j > i , is < d i . (This can be shown by induction) (iii) Using (ii), it follows that the greedy algorithm and optimal algorithm must have the same number of coins of each denomination. 2. (a) Suppose we modify the greedy algorithm for fractional knapsack problem to con- sider the objects in order of “non-increasing” value (rather than non-increasing ratio of value/weight as done in class). Is the modified algorithm still optimal? If so, give an argument for its optimality. If not, give a counterexample. Ans: No. Counterexample:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/06/2012 for the course CS 3230 taught by Professor Sanjay during the Fall '10 term at National University of Singapore.

Page1 / 2

t6ans - CS3230 Tutorial 6 1. Consider the greedy algorithm...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online