Question 71
HardWhich queue discipline does a CPU's round-robin scheduler use?
- A.
FIFO with pre-empted processes rejoining at the back
- B.
Random
- C.
LIFO
- D.
Priority by burst length
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Data Structures and Algorithms
Which queue discipline does a CPU's round-robin scheduler use?
FIFO with pre-empted processes rejoining at the back
Random
LIFO
Priority by burst length
Sign up free to see the answer and a step-by-step explanation.
What is a monotonic queue used for?
Hashing
Keeping window maximums or minimums available in O(1) as the window slides
Finding paths
Sorting
Sign up free to see the answer and a step-by-step explanation.
What problem does a double-ended priority queue (such as a min-max heap) solve?
Detecting cycles
Sorting strings
Finding the median only
Getting both the minimum and the maximum in O(1) and removing either in O(log n)
Sign up free to see the answer and a step-by-step explanation.
How can a queue be implemented with a single stack and recursion?
To dequeue, pop until the stack is empty, take the bottom item, and push the rest back on the way out
It can't
Sort the stack
Push twice
Sign up free to see the answer and a step-by-step explanation.
In a multilevel queue scheduler, what can happen to low-priority queues?
Nothing
They can starve if higher queues always have work
They are deleted
They always run first
Sign up free to see the answer and a step-by-step explanation.
Which is a real-world example of a priority queue?
A playlist in order
A stack of plates
A hospital emergency room triaging patients by urgency
A ticket counter
Sign up free to see the answer and a step-by-step explanation.
In a message queue such as Kafka, what does a consumer offset represent?
The message size
The topic name
The number of consumers
The position up to which the consumer has read in a partition
Sign up free to see the answer and a step-by-step explanation.
What is the advantage of a bounded blocking queue between producers and consumers?
It applies back-pressure: producers wait when consumers fall behind, limiting memory use
It sorts messages
Producers never wait
It removes the need for threads
Sign up free to see the answer and a step-by-step explanation.
What is the maximum size a BFS queue reaches on a perfect binary tree of height h?
About 2^(h−1), the width of the last level
h
2^h × h
1
Sign up free to see the answer and a step-by-step explanation.
A queue is implemented with a Python list using pop(0). Why is this slow?
It uses too little memory
Lists can't store numbers
pop(0) is O(1)
pop(0) shifts every remaining element, costing O(n)
Sign up free to see the answer and a step-by-step explanation.