Deck 5: Queues
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/28
Play
Full screen (f)
Deck 5: Queues
1
Which of the following operations of a queue examines the element at the front of the queue?
A) Enqueue
B) isEmpty
C) size
D) first
A) Enqueue
B) isEmpty
C) size
D) first
first
2
What is the principle difference in behavior between a stack and a queue?
A) a stack reverses order whereas a queue preserves order
B) a stack does nothing whereas a queue can preserve and reverse order
C) there is no difference
D) a stack preserves order whereas a queue reverses order
A) a stack reverses order whereas a queue preserves order
B) a stack does nothing whereas a queue can preserve and reverse order
C) there is no difference
D) a stack preserves order whereas a queue reverses order
a stack reverses order whereas a queue preserves order
3
Queues operate as _______________.
A) Last Out, First In
B) First In, First Out
C) Last In, First Out
D) None of the above
A) Last Out, First In
B) First In, First Out
C) Last In, First Out
D) None of the above
First In, First Out
4
A ______ can be used to preserve the order of a set of data.
A) Queue
B) Stack
C) Software
D) Heaps
A) Queue
B) Stack
C) Software
D) Heaps
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
5
To add an element to a queue you use the____________________ method.
A) push
B) enqueue
C) dequeue
D) pop
A) push
B) enqueue
C) dequeue
D) pop
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
6
The shifting of elements in a noncircular array implementation creates an _______ complexity.
A) O(1)
B) O(n)
C) O(nlogn)
D) O(logn)
A) O(1)
B) O(n)
C) O(nlogn)
D) O(logn)
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
7
A linked implementation of a queue is facilitated by references to the ______ and ______ elements of the linked list.
A) First, second
B) First, middle
C) Middle, last
D) First, last
A) First, second
B) First, middle
C) Middle, last
D) First, last
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
8
When an element is removed from a queue using the dequeue operation, that element is removed from the ____________ of the collection.
A) Front
B) Rear
C) Middle
D) None of the above
A) Front
B) Rear
C) Middle
D) None of the above
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
9
When an element is added to a queue using the enqueue operation, that element is added to the ____________ of the collection.
A) Front
B) Rear
C) Middle
D) None of the above
A) Front
B) Rear
C) Middle
D) None of the above
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
10
A circular array implementation of a queue is more efficient than a fixed array implementation of a queue because elements never have to be ___________.
A) added
B) removed
C) shifted
D) initialized
A) added
B) removed
C) shifted
D) initialized
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
11
If you were to place elements on a collection and then wanted to preserve the order, would it be better to use a Stack or a______?
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
12
What are the 3 primary methods for a queue?______
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
13
A ______ is a linear collection whose elements are added on one end and removed from the other.
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
14
Simulations are often implemented using ______ to represent waiting lines.
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
15
The enqueue and dequeue operations work on ______ ends of the collection.
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
16
When one enqueue's an element to a queue, you add that element to the ____ of the queue.
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
17
When utilizing a circular array for a queue, complete the line of code that updates the value of rear to wrap around the end of the array to the front?
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
18
A ______ implementation of a queue is the preferable array implementation because it does not require elements to be shifted.
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
19
The enqueue and dequeue operations work on opposite ends of the collection.
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
20
The first operation removes an element at the front of the queue and returns a reference to it.
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
21
Queue elements are processed in a FIFO manner-the first element in is the first element out.
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
22
Because queue operations modify both ends of the collection, fixing one end at index 0 eliminates the requirement that elements be shifted.
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
23
Treating arrays as circular eliminates the need to shift elements in an array queue implementation.
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
24
What are some of the other operations that might be implemented for a queue?
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
25
Is it possible for the front and rear references in a linked implementation to be equal?
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
26
Is it possible for the front and rear references in a circular array implementation to be equal?
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
27
Which implementation has the worst time complexity?
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck
28
Which implementation has the worst space complexity?
Unlock Deck
Unlock for access to all 28 flashcards in this deck.
Unlock Deck
k this deck