Deck 7: Queues and Deques

Full screen (f)
exit full mode
Question
A queue is a LIFO (last-in, first-out) list.
Use Space or
up arrow
down arrow
to flip the card.
Question
The last element placed in a queue is the only visible item.
Question
Which of the following functions represents an operation that is specified in a Queue ADT?

A) sort
B) top
C) front
D) merge
Question
Consider the following set of operations performed against a string type queue called my_queue.
<strong>Consider the following set of operations performed against a string type queue called my_queue.   Which string is output?</strong> A) First B) First Come C) First Serve D) Serve <div style=padding-top: 35px> Which string is output?

A) First
B) First Come
C) First Serve
D) Serve
Question
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
Question
A queue is similar to a(n) __________ in that you can insert an item at one end and remove it from the other.
Question
The standard library defines the queue as a(n) __________ class that takes any of the sequential containers as a template parameter.
Question
Insertions are at the __________ of a queue, and removals are from the front.
Question
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
Question
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."
Question
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!)
Question
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)#
Question
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
Question
In the Array_Queue.tc, the cost of reallocating is __________ across each insert operation.
Question
All three implementations of the Queue ADT are comparable in terms of computation time.
Question
C++ stores a copy of the data for a queue element in each node in addition to the links.
Question
A(n) __________ is an abstract data type that combines the features of a stack and a queue.
Question
The std::deque supports random-access __________ (not supported by either the stack or the queue).
Question
The current capacity of the deque is defined by the size of the circular array times the size of a(n) __________ block.
Question
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()); <div style=padding-top: 35px>

A) deleter[] num_items;
B) delete[] the_data.front();
C) delete[] offset;
D) delete(the data_front());
Question
__________ is a technique used to study the performance of a physical system by using a physical, mathematical, or computer model of the system.
Question
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
Question
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 __________.
Question
In the simulation for serving airline customers, the queue data structure is utilized to store Agent objects.
Question
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
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/25
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
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
front
4
Consider the following set of operations performed against a string type queue called my_queue.
<strong>Consider the following set of operations performed against a string type queue called my_queue.   Which string is output?</strong> A) First B) First Come C) First Serve D) Serve Which string is output?

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
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
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!)
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)#
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
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());

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
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
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 25 flashcards in this deck.