Data Structures & AlgorithmsModerateTCS NQT · Accenture

Problem: A process list is [3, 7, 2, 9] with priorities; the CPU always runs the largest value next and runs it for its full value, then removes it. Running in this way, what is the completion time of the process with value 2 (the time counted as the total units run before it finishes)?

  1. A. 19
  2. B. 12
  3. C. 21
  4. D. 2

Correct answer: C. 21

Largest-first order is 9, 7, 3, 2, so process 2 finishes at 9 + 7 + 3 + 2 = 21. Its start time is 19, running in listed order would finish it at 3 + 7 + 2 = 12, and shortest-first would finish it at 2.

More Coding Interview Problems questions

Exams that ask this topic