Deck 7: Queues and Deques
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/25
Play
Full screen (f)
Deck 7: Queues and Deques
1
A queue is a LIFO (last-in, first-out) list.
False
2
The last element placed in a queue is the only visible item.
False
3
Which of the following functions represents an operation that is specified in a Queue ADT?
A) sort
B) top
C) front
D) merge
A) sort
B) top
C) front
D) merge
front
4
Consider the following set of operations performed against a string type queue called my_queue.
Which string is output?
A) First
B) First Come
C) First Serve
D) Serve

A) First
B) First Come
C) First Serve
D) Serve
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
5
If exercised first, which of the following choices in the Maintain_Queue program will cause a run-time error?
A) pop
B) push
C) front
D) size
A) pop
B) push
C) front
D) size
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
6
A queue is similar to a(n) __________ in that you can insert an item at one end and remove it from the other.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
7
The standard library defines the queue as a(n) __________ class that takes any of the sequential containers as a template parameter.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
8
Insertions are at the __________ of a queue, and removals are from the front.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
9
The number of elements in an instance of Linked_Queue.tc is changed by functions push and __________.
A) empty
B) size
C) front
D) pop
A) empty
B) size
C) front
D) pop
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
10
A complete definition and implementation of the queue class would include a copy constructor, assignment operator, swap function, and __________ as required by the "rule of three."
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
11
Shifting the elements in a queue based on a linear array is an __________ operation.
A) O(1)
B) O(n)
C) O(n2)
D) O(n!)
A) O(1)
B) O(n)
C) O(n2)
D) O(n!)
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
12
Suppose my_queue contains the symbols % $ @ ! #in order from front to rear. After three pop operations, which symbol is at the front of the queue?
A) $
B) @
C) !
D)#
A) $
B) @
C) !
D)#
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
13
Suppose that circular_queue, which is based on a circular array, stores the items 1, 1, 2, 3, 5, 8 in order from front to rear. If the first two items are deleted, which element does the rear marker point to?
A) 2
B) 3
C) 5
D) 8
A) 2
B) 3
C) 5
D) 8
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
14
In the Array_Queue.tc, the cost of reallocating is __________ across each insert operation.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
15
All three implementations of the Queue ADT are comparable in terms of computation time.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
16
C++ stores a copy of the data for a queue element in each node in addition to the links.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
17
A(n) __________ is an abstract data type that combines the features of a stack and a queue.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
18
The std::deque supports random-access __________ (not supported by either the stack or the queue).
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
19
The current capacity of the deque is defined by the size of the circular array times the size of a(n) __________ block.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
20
Which of the following is the critical line missing from the dequeu class pop_front () function?
![<strong>Which of the following is the critical line missing from the dequeu class pop_front () function? </strong> A) deleter[] num_items; B) delete[] the_data.front(); C) delete[] offset; D) delete(the data_front());](https://d2lvgg3v3hfg70.cloudfront.net/TB10563/11eec35c_d7df_7ea5_ae1f_1d85525ad632_TB10563_00.jpg)
A) deleter[] num_items;
B) delete[] the_data.front();
C) delete[] offset;
D) delete(the data_front());
![<strong>Which of the following is the critical line missing from the dequeu class pop_front () function? </strong> A) deleter[] num_items; B) delete[] the_data.front(); C) delete[] offset; D) delete(the data_front());](https://d2lvgg3v3hfg70.cloudfront.net/TB10563/11eec35c_d7df_7ea5_ae1f_1d85525ad632_TB10563_00.jpg)
A) deleter[] num_items;
B) delete[] the_data.front();
C) delete[] offset;
D) delete(the data_front());
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
21
__________ is a technique used to study the performance of a physical system by using a physical, mathematical, or computer model of the system.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
22
In the context of serving airline passengers, a(n) "__________" strategy would be to serve any frequent flyer waiting in line before serving the regular passengers.
A) democratic
B) global
C) elitist
D) biased
A) democratic
B) global
C) elitist
D) biased
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
23
To run a computer simulation, we must keep track of the current time by maintaining a clock that is set to an initial time of __________.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
24
In the simulation for serving airline customers, the queue data structure is utilized to store Agent objects.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
25
In object-oriented design, when one object sends a __________ to another, the receiving object should have a function that sends a response.
A) frame
B) datagram
C) packet
D) message
A) frame
B) datagram
C) packet
D) message
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck