🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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]))
  1. A.X 3.0
  2. B.Y 4.0
  3. C.Z 2.0
  4. 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 →