Data Structures & AlgorithmsVery hardTCS NQT Digital · Product Company SDE

Problem: Four processes arrive at times 0, 2, 4, 6 with burst times 6, 2, 8, 3. The scheduler is shortest-remaining-time-first (preemptive). What is the completion time of the process that arrives at time 4?

  1. A. 16
  2. B. 19
  3. C. 15
  4. D. 11

Correct answer: B. 19

SRTF: P1 runs 0-2, P2 (2 units) preempts it and finishes at 4, P1 finishes at 8, P4 runs 8-11, and P3 (arrival 4, burst 8) runs last to 19. FCFS order would finish P3 at 16, its turnaround time is 19 − 4 = 15, and 11 is P4's completion time.

More Coding Interview Problems questions

Exams that ask this topic