GATE Computer ScienceVery hardGATE CS (PYQ pattern)

Intervals (start, end, weight) are (0,3,4), (1,5,6), (2,6,10), (5,8,7), (4,9,9), (7,10,3), (9,12,8), (8,13,5), (12,15,6), (10,16,12); two intervals are compatible when one ends no later than the other starts. The maximum total weight of a set of pairwise compatible intervals is:

  1. A. 25
  2. B. 26
  3. C. 31
  4. D. 27

Correct answer: D. 27

Weighted interval scheduling DP over intervals sorted by end time gives 27 (confirmed by brute force over all 1024 subsets). Both the earliest-finish greedy and the heaviest-first greedy yield only 25, and 31 is the unattainable sum of the three heaviest overlapping intervals.

More Algorithms questions

Exams that ask this topic