t6 - CS3230 Tutorial 6 1. Consider the greedy algorithm for...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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. 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. (b) Suppose we modify the greedy algorithm to consider the objects in order of “non- decreasing” weight (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. 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.

Ask a homework question - tutors are online