Data Structures & AlgorithmsVery hardGATE CSE · Advanced

Eight trains have arrival times 900, 915, 930, 945, 1000, 1010, 1030, 1100 and departure times (in some order) 930, 1000, 1015, 1000, 1100, 1030, 1200, 1130. A platform vacated at a given time can serve a train arriving at that same time. What is the minimum number of platforms needed?

  1. A. 3
  2. B. 2
  3. C. 4
  4. D. 5

Correct answer: A. 3

Sort arrivals and departures and sweep, processing a departure before an arrival at equal times; the count peaks at 3 (if ties were handled the other way it would wrongly read 4).

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic