## Help authour, Buy PDF Ebook
>>>**Click Here**<<<

## Data Structure Questions and Answers-Coin Change Problem

## Click on any option to know the CORRECT ANSWERS

Question 1 |

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 .....

Greedy algorithm | |

Dynamic programming | |

Divide and conquer | |

All of the mentioned |

**Biology Questions answers**

Question 1 Explanation:

The coin change problem has overlapping subproblems(same subproblems are solved multiple times) and optimal substructure(the solution to the problem can be found by finding optimal solutions for subproblems). So, dynamic programming can be used to solve the coin change problem.

Question 2 |

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 NOT produce an optimal answer?

20 | |

12 | |

6 | |

5 |

**GK Questions answers**

Question 2 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}.

Question 3 |

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?

14 | |

10 | |

6 | |

100 |

**History Questions answers**

Question 3 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}.

Question 4 |

Fill in the blank to complete the code.

#include<stdio.h> int main() { int coins[10]={1, 3, 4}, lookup[100000]; int i, j, tmp, num....coins = 3, sum=100; lookup[0]=0; for(i = 1; i <= sum; i++) { int min....coins = i; for(j = 0;j < num....coins; j++) { tmp = i - coins[j]; if(tmp < 0) continue; if(lookup[tmp] < min....coins) .....; } lookup[i] = min....coins + 1; } printf("%d", lookup[sum]); return 0; }

lookup[tmp] = min....coins | |

min....coins = lookup[tmp] | |

break | |

continue |

**English literature Questions answers**

Question 4 Explanation:

min....coins = lookup[tmp] will complete the code.

Question 5 |

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?

O(N) | |

O(S) | |

O(N ^{2}) | |

O(S*N) |

**History Questions answers**

Question 5 Explanation:

The time complexity is O(S*N).

There are 5 questions to complete.