adplus-dvertising
frame-decoration

Question

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;
}

a.

lookup[tmp] = min_coins

b.

min_coins = lookup[tmp]

c.

break

d.

continue

Answer: (b).min_coins = lookup[tmp]

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Fill in the blank to complete the code.

Similar Questions

Discover Related MCQs

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

Q. Suppose 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 space complexity of a dynamic programming implementation used to solve the coin change problem?

Q. You are given infinite coins of denominations 1, 3, 4. What is the total number of ways in which a sum of 7 can be achieved using these coins if the order of the coins is not important?

Q. You are given infinite coins of denominations 1, 3, 4. What is the minimum number of coins required to achieve a sum of 7?

Q. You are given infinite coins of denominations 5, 7, 9. Which of the following sum CANNOT be achieved using these coins?

Q. You are given infinite coins of denominations 3, 5, 7. Which of the following sum CAN be achieved using these coins?

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?

Q. Find the maximum sub-array sum for the given elements.
{2, -1, 3, -4, 1, -2, -1, 5, -4}

Q. Find the maximum sub-array sum for the given elements.
{-2, -1, -3, -4, -1, -2, -1, -5, -4}

Q. What is the time complexity of the naive method used to find the maximum sub-array sum in an array containing n elements?

Q. What is the space complexity of the naive method used to find the maximum sub-array sum in an array containing n elements?

Q. What is the time complexity of the divide and conquer algorithm used to find the maximum sub-array sum?

Q. What is the space complexity of the divide and conquer algorithm used to find the maximum sub-array sum?

Q. Find the maximum sub-array sum for the following array:
{3, 6, 7, 9, 3, 8}

Q. Kadane’s algorithm is used to find ____________

Q. Kadane’s algorithm uses which of the following techniques?

Q. For which of the following inputs would Kadane’s algorithm produce the CORRECT output?

Q. For which of the following inputs would Kadane’s algorithm produce a WRONG output?

Q. What is the time complexity of Kadane’s algorithm?

Q. What is the space complexity of Kadane’s algorithm?