This preview shows page 1. Sign up to view the full content.
Unformatted text preview: CS3230 Tutorial 6 1. Consider the greedy algorithm for coinchange 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. 2. (a) Suppose we modify the greedy algorithm for fractional knapsack problem to con sider the objects in order of “nonincreasing” value (rather than nonincreasing 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. (b) Suppose we modify the greedy algorithm to consider the objects in order of “non decreasing” weight (rather than nonincreasing 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. 3. Using the algorithm done in class, give Huffman tree and code if the frequencies of the letters are as follows: freq ( a ) = 25,...
View
Full
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.
 Fall '10
 sanjay
 Algorithms

Click to edit the document details