Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: A list of 6 customers arrives at a bank counter with service times 4, 1, 3, 2, 6, 5 (in that arrival order). The counter serves them in shortest-job-first order (all present at time 0, non-preemptive). What is the average waiting time (time spent before service starts), as a whole number after truncation?

  1. A. 6
  2. B. 4
  3. C. 5
  4. D. 7

Correct answer: C. 5

Shortest-job-first minimises total waiting by serving short jobs first; each customer waits for the sum of the services before it. Using the arrival order instead gives a larger average.

More Coding Interview Problems questions

Exams that ask this topic