GATE Computer ScienceVery hardGATE CS (PYQ pattern)
The fractional knapsack greedy algorithm (taking items by value/weight ratio, the last one fractionally) is run on capacity 26 and items (weight, value): (12, 24), (7, 13), (11, 23), (8, 15), (9, 16), (6, 11). By how much does its optimal value exceed the optimal 0/1 knapsack value of this instance?
- A. 1.625
- B. 1.5
- C. 0.625
- D. 2.625
Correct answer: A. 1.625
Ratios: 23/11 = 2.09, 24/12 = 2, 15/8 = 1.875, ...: take (11, 23) and (12, 24) fully (weight 23), then 3/8 of (8, 15) = 5.625, total 52.625. The 0/1 optimum is 51, so the gap is 1.625.
More Algorithms questions
- Dijkstra's algorithm (never re-inserting or re-opening a vertex once it has been extracted) is run from S on a directed graph with edges…
- Dijkstra's algorithm with a binary min-heap (lazy insertion is not used: a decrease-key is performed whenever an edge improves the label…
- In the undirected weighted graph with edges SA 1, SB 1, SC 2, AD 2, BD 2, CD 1, AE 3, BE 3, CE 2, DT 2, ET 1 and AB 1, how many distinct…
- Bellman–Ford is run from A on a 6-vertex graph with directed edges relaxed in this fixed order in every pass: E→F 2, D→E 3, C→D 2, B→C 4…
- A weighted undirected graph has vertices A–F and edges AB 1, BC 1, CA 1, CD 2, DE 2, EC 2, EF 3, FD 3, AF 7. How many distinct minimum…
- A weighted undirected graph on vertices A–G has edges AB 4, AC 8, BC 2, BD 5, CD 9, CE 10, DE 3, DF 11, EF 4, EG 7, FG 5, BG 20. Its MST…