Data Structures & AlgorithmsHardTCS NQT Digital · Product Company SDE
Problem: Round-robin scheduling with time quantum 3 is applied to processes that all arrive at time 0: P1 needs 7 units, P2 needs 4, P3 needs 9, in the queue order P1, P2, P3. A process that still needs time goes to the back of the queue. What is the finish time of P3?
- A. 17
- B. 16
- C. 11
- D. 20
Correct answer: D. 20
Slices: P1 0-3, P2 3-6, P3 6-9, P1 9-12, P2 12-13 (done), P3 13-16, P1 16-17 (done), P3 17-20 (done), so P3 finishes at 20. 17 is P1's finish time, 16 ends P3's second slice (forgetting that 9 units need three slices), and 11 is P3's waiting time, not its finish time.
More Coding Interview Problems questions
- Problem: Josephus game: n = 37 people stand in a circle numbered 1 to 37. Starting from person 1, every 4th person is removed (counting…
- Problem: A deque starts empty. Operations in order: pushback(5), pushfront(2), pushback(8), popfront(), pushfront(9), pushback(1)…
- Problem: How many integers x in the range 1 ≤ x ≤ 1000 have exactly 4 set bits in their binary representation?
- Problem: A staircase can be climbed by steps of size 1, 3 or 4. How many distinct ordered sequences of steps climb exactly 13 stairs?
- Problem: What is the length of the longest strictly increasing subsequence of the sequence 10, 9, 2, 5, 3, 7, 101, 18, 4, 6, 8, 1, 12?
- Problem: Coins of denominations 5, 12 and 20 are available in unlimited supply. What is the minimum number of coins needed to make exactly…