Data Structures & AlgorithmsVery hardGATE CS · TCS NQT
Three processes arrive at time 0 with CPU bursts 5, 3 and 8. Round-robin scheduling uses a time quantum of 2, a process that is not finished goes to the back of the queue, and the order starts with P1, P2, P3. At what time does P3 finish?
- A. 14
- B. 19
- C. 16
- D. 21
Correct answer: C. 16
Simulate the queue slice by slice: each process runs for min(quantum, remaining) and rejoins the back if it still has work. Forgetting the re-queue step gives a much smaller value.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- Remove exactly 3 digits from the number 1432219 (without reordering the rest) so that the remaining number is as small as possible. What…
- Repeatedly delete any two adjacent equal characters from the string abbacbaca until no such pair exists. How many characters remain?
- How many substrings of length exactly 4 of the string abbaccddcc are palindromes?
- What is the sum, over all contiguous windows of length 3, of the number of distinct values in the window, for the array [1, 2, 1, 3, 4, 2…
- How many index pairs i < j in the array [12, 21, 3, 30, 111, 9, 18] have numbers with equal digit sums?
- How many index pairs i < j in the array [1, 2, 3, 4, 6, 7, 8, 9] have a[i] a[j] mod 5 = 1?