(1) What kind of algorithm is this? A. Dynamic Programing B. Greedy Algorithm C. Divide and Conquer D. None of the above (2) Is the above algorithm always optimal?

icon
Related questions
Question
100%
Given any set of currency denominations C = {C₁,C₂,C}. The goal is to devise a method
to pay a given amount, say x, to the customer using the fewest coins. Here is an algorithm
as follows:
ALGORITHM (X,C)
SORT the n coin denominations in C so that 0 < ₁ <C₂ <... < C
S = Ø.
WHILE (x > 0)
k = largest coin denomination ck such that C₂ ≤X.
IF (no such k)
ELSE
RETURN "no solution."
X = X-Ck
S-SU{k}.
RETURN S.
(1) What kind of algorithm is this?
A. Dynamic Programing
B. Greedy Algorithm
C. Divide and Conquer
D. None of the above
(2) Is the above algorithm always optimal?
A. Yes, for any set of coin denominations c₁ < c₂ <... < c provided c₁
= 1.
B. Yes, because of special properties of U.S. coin denominations.
C. No, the algorithm won't return an optimal solution for some sets of coin
denominations.
D. No, the algorithm won't return an optimal solution for any set of coin
denominations.
Transcribed Image Text:Given any set of currency denominations C = {C₁,C₂,C}. The goal is to devise a method to pay a given amount, say x, to the customer using the fewest coins. Here is an algorithm as follows: ALGORITHM (X,C) SORT the n coin denominations in C so that 0 < ₁ <C₂ <... < C S = Ø. WHILE (x > 0) k = largest coin denomination ck such that C₂ ≤X. IF (no such k) ELSE RETURN "no solution." X = X-Ck S-SU{k}. RETURN S. (1) What kind of algorithm is this? A. Dynamic Programing B. Greedy Algorithm C. Divide and Conquer D. None of the above (2) Is the above algorithm always optimal? A. Yes, for any set of coin denominations c₁ < c₂ <... < c provided c₁ = 1. B. Yes, because of special properties of U.S. coin denominations. C. No, the algorithm won't return an optimal solution for some sets of coin denominations. D. No, the algorithm won't return an optimal solution for any set of coin denominations.
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Similar questions