GATE Computer ScienceModerateGATE CS
A 0/1 knapsack has capacity 50 and items given as (value, weight): (60, 10), (100, 20), (120, 30), (75, 25). The maximum total value is:
- A. 220
- B. 240
- C. 160
- D. 175
Correct answer: A. 220
The best choice is the items (100, 20) and (120, 30), with weight 50 and value 220. 240 is the fractional-knapsack optimum, and 160 is what the greedy-by-ratio rule gets for the 0/1 version.
More Algorithms questions
- Which of the following statements are correct? (I) 2-SAT can be solved in polynomial time. (II) Subset-sum has a pseudo-polynomial…
- An AVL tree is a binary search tree in which the heights of the two subtrees of every node differ by at most 1. Taking the height of a…
- A B-tree has minimum degree t = 3 (every node other than the root holds between t − 1 and 2t − 1 keys; the root holds at least 1 key) and…
- A DAG has vertices 1 to 8 and edges 1→3, 2→3, 3→4, 3→5, 2→6, 6→5, 4→7, 5→7, 8→6, 1→8. How many different topological orderings does it have?
- A directed graph on vertices 0 to 11 has edges 0→1, 1→2, 2→0, 2→3, 3→4, 4→3, 5→3, 5→6, 6→7, 7→6, 8→9, 9→10, 10→8, 10→5, 11→3. What is the…
- An undirected graph has vertices 0 to 13 and edges 0-1, 1-2, 2-0, 2-3, 3-4, 4-5, 5-3, 5-6, 6-7, 7-8, 8-6, 1-9, 9-10, 10-11, 11-9, 4-12…