← Quiz: CPU Scheduling Numericals: all 14 questions
Quiz: CPU Scheduling Numericals · Question 13 of 14
What does this print? (code)
What does this print?
def ratio(waited, burst):
return (waited + burst) / burst
jobs = {"X": (8, 4), "Y": (3, 1), "Z": (10, 10)}
best = max(jobs, key=lambda j: ratio(*jobs[j]))
print(best, ratio(*jobs[best]))
- A.X 3.0
- B.Y 4.0
- C.Z 2.0
- D.Z 20.0
Answer & explanation
Correct answer: Y 4.0
X = 12/4 = 3, Y = 4/1 = 4, Z = 20/10 = 2. HRRN runs the largest ratio, Y.
Can you get the rest right without peeking?
Take the timed Quiz: CPU Scheduling Numericals quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →