GATE CSE 2018 Q58: Optimal minus greedy value for 0/1 knapsack with capacity 11
- Algorithms
- 2 marks
- NAT
- No negative marking
Syllabus topic: Algorithm design techniques: greedy, dynamic programming and divide-and-conquer
Question
Consider the weights and values of items listed below. Note that there is only one unit of each item.
| Item number | Weight (in Kgs) | Value (in Rupees) |
|---|---|---|
| 1 | 10 | 60 |
| 2 | 7 | 28 |
| 3 | 4 | 20 |
| 4 | 2 | 24 |
The task is to pick a subset of these items such that their total weight is no more than 11 Kgs and their total value is maximized. Moreover, no item may be split. The total value of items picked by an optimal algorithm is denoted by . A greedy algorithm sorts the items by their value-to-weight ratios in descending order and packs them greedily, starting from the first item in the ordered list. The total value of items picked by the greedy algorithm is denoted by .
The value of is ____________.
Try it: numerical answer: type the value
Show answer and explanation
Answer: 16 (official GATE 2018 final answer key)
Concept used: Greedy by value-to-weight ratio is optimal for fractional knapsack but can be suboptimal for 0/1 knapsack.
First step: Compute each item's value/weight ratio, simulate the greedy packing with capacity 11, and separately check all feasible subsets for the optimum.
Full step-by-step solution
Loading…
Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.
More questions on Algorithm design techniques: greedy, dynamic programming and divide-and-conquer
Every PYQ on this topic →Share this question
Source: official GATE 2018 CS question paper and final answer key, organised by IIT Guwahati. Question paper · Answer key
More Algorithms PYQs
- 2026 Session 1 · Q17Solve nested recurrences T1 = 4T1(n/2) + T2, T2 = 5T2(n/4) + log n
- 2026 Session 1 · Q41Shortest paths with at most k edges: two statements
- 2026 Session 1 · Q47Condition forcing a vertex into every minimum vertex cover
- 2026 Session 1 · Q49Cycle and cut properties of MSTs with distinct weights
- 2026 Session 1 · Q50Impossible DFS discovery/finish orderings for a DAG edge
- 2026 Session 1 · Q55Properties of 2-colorable (bipartite) graphs