{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

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, freq ( b ) = 2, freq ( c ) = 5, freq ( d ) = 6, freq ( e ) = 6, freq ( f ) = 6 4. Suppose T is a Huffman coding tree for the frequencies f 1 , f 2 , f 3 , . . . , f
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Ask a homework question - tutors are online