All problems
Round-Robin Scheduling
Problem
Simulate round-robin scheduling and return the process ids in completion order.
Each process runs for at most one quantum, and unfinished processes go to the back of the queue with their remaining time. Assume quantum >= 1 and process ids are unique.
Hint
A queue with a moving head position avoids repeated list removals.
Test cases
case 1
in: [[[1,5],[2,3],[3,1]],2]
expected: [3,2,1]
case 2
in: [[[1,2]],1]
expected: [1]
case 3
in: [[[1,1],[2,1]],5]
expected: [1,2]
case 4
in: [[],2]
expected: []
case 5
in: [[[1,3],[2,3]],2]
expected: [1,2]
Starter codePython
def round_robin(processes, quantum):
# Your code here
pass5 test cases · run your code against them in the editor