CS3230Tutorial 61. Consider the greedy algorithm for coin-change problem.Suppose the coin denominations ared1> d2> . . . > dn= 1.Suppose thatdi+1is a factor ofdi, 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 ofvalue/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 theletters are as follows:freq(a) = 25,freq(b) = 2,freq(c) = 5,freq(d) = 6,freq(e) = 6,freq(f) = 64. SupposeTis a Huffman coding tree for the frequenciesf1, f2, f3, . . . , f
This is the end of the preview.
access the rest of the document.