McqMate

Q. |
## Suppose you have coins of denominations 1,3 and 4. You use a greedy algorithm, in which you choose the largest denomination coin which is not greater than the remaining sum. For which of the following sums, will the algorithm produce an optimal answer? |

A. | 14 |

B. | 10 |

C. | 6 |

D. | 100 |

Answer» D. 100 | |

Explanation: using the greedy algorithm, three coins {4,1,1} will be selected to make a sum of 6. but, the optimal answer is two coins {3,3}. similarly, four coins {4,4,1,1} will be selected to make a sum of 10. but, the optimal answer is three coins {4,3,3}. also, five coins {4,4,4,1,1} will be selected to make a sum of 14. but, the optimal answer is four coins {4,4,3,3}. for a sum of 100, twenty-five coins {all 4’s} will be selected and the optimal answer is also twenty-five coins {all 4’s}. |

719

0

Do you find this helpful?

0

View all MCQs in

Design and Analysis of Algorithms2 months ago

NOT PRODUCE

-1

- You are given infinite coins of N denominations v1, v2, v3,…..,vn and a sum S. The coin change problem is to find the minimum number of coins required to get the sum S. What is the time complexity of a dynamic programming implementation used to solve the coin change problem?
- You are given infinite coins of denominations v1, v2, v3,…..,vn and a sum S. The coin change problem is to find the minimum number of coins required to get the sum S. This problem can be solved using
- You are given infinite coins of denominations 1, 3, 4. What is the minimum number of coins required to achieve a sum of 7?
- A greedy algorithm can be used to solve all the dynamic programming problems.
- The 0-1 Knapsack problem can be solved using Greedy algorithm.
- The first step in the naïve greedy algorithm is?
- You are given n dice each having f faces. You have to find the number of ways in which a sum of S can be achieved. This is the dice throw problem. Which of the following methods can be used to solve the dice throw problem?
- Consider the 2×3 matrix {{1,2,3},{1,2,3}}. What is the sum of elements of the maximum sum rectangle?
- Consider the 2×2 matrix {{-1,-2},{-3,-4}}. What is the sum of elements of the maximum sum rectangle?
- What is the worst case time complexity of dynamic programming solution of set partition problem(sum=sum of set elements)?