Computer Science EngineeringHardISRO SC (CS)
0/1 knapsack: item weights [4, 3, 3, 8, 7], values [18, 11, 18, 8, 4], capacity 15. The maximum total value is:
- A. 47
- B. 46
- C. 50
- D. 45
Correct answer: A. 47
DP over capacity gives 47; the greedy value/weight-ratio choice yields 47, which need not be optimal.
Practise more Algorithms, Data Structures & Programming (ISRO CS) questionsAlgorithms, Data Structures & Programming (ISRO CS): notes and key points
More Algorithms, Data Structures & Programming (ISRO CS) questions
- The number of distinct spanning trees of the complete bipartite graph K2,4 is:
- The number of distinct permutations of 1..6 that can be produced as output by pushing 1,2,...,6 in order onto a stack and popping at any…
- The number of distinct combinations (order ignored) of coins from [2, 5, 3, 6] (unlimited supply of each) that sum to 10 is:
- The minimum number of coins needed to make 6 from denominations [1, 3, 4] (unlimited supply) is:
- Consider the following C fragment. int c=0; for(int i=1;i<=1000;i=2) for(int j=1;j<=i;j++) c++; What is c at the end?
- The naive string-matching algorithm slides pattern AAB over text AAAAAAAB, comparing characters left to right and abandoning an alignment…