Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: A queue of 5 customers arrives with service times 4, 2, 6, 1, 3. A single server processes them in order (first come first served). What is the average waiting time before service starts, rounded down to an integer?

  1. A. 10
  2. B. 4
  3. C. 7
  4. D. 8

Correct answer: C. 7

Waits are 0, 4, 6, 12, 13, totalling 35, so the average is 7. Including service times (turnaround) gives 10, shortest-job-first gives 4, and dividing by 4 instead of 5 gives 8.

More Coding Interview Problems questions

Exams that ask this topic