Question
#include<stdio.h>
int main()
{
int coins[10]={1,3,4},lookup[100];
int i,j,tmp,num_coins = 3,sum=10;
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)
min_coins=lookup[tmp];
}
lookup[i] = min_coins + 1;
}
printf("%d",lookup[sum]);
return 0;
}
a.
2
b.
3
c.
4
d.
5
Posted under Data Structures and Algorithms
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. What is the output of the following program?
Similar Questions
Discover Related MCQs
Q. Given a one-dimensional array of integers, you have to find a sub-array with maximum sum. This is the maximum sub-array sum problem. Which of these methods can be used to solve the problem?
View solution
Q. Find the maximum sub-array sum for the given elements.
{2, -1, 3, -4, 1, -2, -1, 5, -4}
View solution
Q. Find the maximum sub-array sum for the given elements.
{-2, -1, -3, -4, -1, -2, -1, -5, -4}
View solution
Q. What is the time complexity of the naive method used to find the maximum sub-array sum in an array containing n elements?
View solution
Q. What is the space complexity of the naive method used to find the maximum sub-array sum in an array containing n elements?
View solution
Q. What is the time complexity of the divide and conquer algorithm used to find the maximum sub-array sum?
View solution
Q. What is the space complexity of the divide and conquer algorithm used to find the maximum sub-array sum?
View solution
Q. Find the maximum sub-array sum for the following array:
{3, 6, 7, 9, 3, 8}
View solution
Q. Kadane’s algorithm is used to find ____________
View solution
Q. Kadane’s algorithm uses which of the following techniques?
View solution
Q. For which of the following inputs would Kadane’s algorithm produce the CORRECT output?
View solution
Q. For which of the following inputs would Kadane’s algorithm produce a WRONG output?
View solution
Q. What is the time complexity of Kadane’s algorithm?
View solution
Q. What is the space complexity of Kadane’s algorithm?
View solution
Q. The longest increasing subsequence problem is a problem to find the length of a subsequence from a sequence of array elements such that the subsequence is sorted in increasing order and it’s length is maximum. This problem can be solved using __________
View solution
Q. Find the longest increasing subsequence for the given sequence:
{10, -10, 12, 9, 10, 15, 13, 14}
View solution
Q. Find the length of the longest increasing subsequence for the given sequence:
{-10, 24, -9, 35, -21, 55, -41, 76, 84}
View solution
Q. For any given sequence, there will ALWAYS be a unique increasing subsequence with the longest length.
View solution
Q. The number of increasing subsequences with the longest length for the given sequence are:
{10, 9, 8, 7, 6, 5}
View solution
Q. In the brute force implementation to find the longest increasing subsequence, all the subsequences of a given sequence are found. All the increasing subsequences are then selected and the length of the longest subsequence is found. What is the time complexity of this brute force implementation?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Data Structures and Algorithms? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!