Question 11
EasyWhat is queue underflow?
- A.
Trying to dequeue from an empty queue
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Data Structures and Algorithms
What is queue underflow?
Trying to dequeue from an empty queue
A queue with one element
Adding to a full queue
A queue that is too long
Sign up free to see the answer and a step-by-step explanation.
Which Python class gives O(1) adds and removes at both ends and is recommended for queues?
list
set
collections.deque
tuple
Sign up free to see the answer and a step-by-step explanation.
Which Java interface represents a FIFO queue, implemented by classes such as LinkedList and ArrayDeque?
Set
Stack
Map
Queue
Sign up free to see the answer and a step-by-step explanation.
Which data structure does Round Robin CPU scheduling use to hold the ready processes?
A stack
A queue
A hash table
A binary search tree
Sign up free to see the answer and a step-by-step explanation.
Which data structure is used for the level-order traversal of a tree?
A queue
A hash set
A stack
A heap
Sign up free to see the answer and a step-by-step explanation.
At which ends can elements be added in a deque?
Only the rear
Only the front
Only the middle
Both the front and the rear
Sign up free to see the answer and a step-by-step explanation.
What is an input-restricted deque?
A deque where elements can be added at only one end but removed from both
A deque that cannot be used for input
A deque where elements can only be removed from one end
A deque with a fixed size of one
Sign up free to see the answer and a step-by-step explanation.
What is the output of this code?
from collections import deque
q = deque([1, 2, 3])
q.append(4)
q.popleft()
print(list(q))
[2, 3, 4]
[1, 2, 3]
Sign up free to see the answer and a step-by-step explanation.
What is the output of this code?
from collections import deque
q = deque([1, 2, 3])
q.appendleft(0)
q.pop()
print(list(q))
[1, 2, 3]
[1, 2]
Sign up free to see the answer and a step-by-step explanation.
When a queue is built from a singly linked list, where should enqueue and dequeue happen for O(1) time?
Both at the head
Enqueue at the head and dequeue at the tail
Enqueue at the tail and dequeue at the head
Both at the tail
Sign up free to see the answer and a step-by-step explanation.
[1, 2, 3, 4]
[2, 3]
[0, 1, 2, 3]
[0, 1, 2]