Data Structures & AlgorithmsHardTCS NQT Digital · Product Company SDE

Problem: Round-robin scheduling with time quantum 3 is applied to processes that all arrive at time 0: P1 needs 7 units, P2 needs 4, P3 needs 9, in the queue order P1, P2, P3. A process that still needs time goes to the back of the queue. What is the finish time of P3?

  1. A. 17
  2. B. 16
  3. C. 11
  4. D. 20

Correct answer: D. 20

Slices: P1 0-3, P2 3-6, P3 6-9, P1 9-12, P2 12-13 (done), P3 13-16, P1 16-17 (done), P3 17-20 (done), so P3 finishes at 20. 17 is P1's finish time, 16 ends P3's second slice (forgetting that 9 units need three slices), and 11 is P3's waiting time, not its finish time.

More Coding Interview Problems questions

Exams that ask this topic