All problems
Round-Robin Response Times
Problem
Deterministically simulate round-robin scheduling for jobs with the given service times that all arrive at time 0, using the given time quantum. Rotate through unfinished jobs giving each at most quantum units. Return the list of completion times in the original job order.
Return an empty list for an empty input or quantum <= 0.
Hint
Each pass through the job list advances the clock by up to one quantum per job.
Test cases
case 1
in: [[1,1,1],1]
expected: [1,2,3]
case 2
in: [[5,1],1]
expected: [6,2]
case 3
in: [[2,3],10]
expected: [2,5]
case 4
in: [[],1]
expected: []
case 5
in: [[1],0]
expected: []
Starter codePython
def round_robin_response_times(services, quantum):
# Your code here
pass5 test cases · run your code against them in the editor