Deck 18: Stacks and Queues

Full screen (f)
exit full mode
Question
A ________ is processed in a manner similar to customers standing in a grocery check-out line-the first customer in line is the first served.

A)stack
B)vector
C)queue
D)All of these
E)None of these
Use Space or
up arrow
down arrow
to flip the card.
Question
The Standard Template Library offers a stack template that may be implemented as a:

A)vector
B)deque
C)linked list
D)All of these
E)None of these
Question
A dynamic stack has a ________ size, and is implemented as a(n)________.

A)variable, linked list
B)fixed, linked list
C)variable, array
D)fixed, array
E)None of these
Question
Two primary queue operations are:

A)push and pop
B)enqueue and dequeue
C)insert and delete
D)onqueue and offqueue
E)None of these
Question
A dynamic stack may be implemented as a(n)________, and expand or shrink with each push or pop operation.

A)array
B)structure
C)linked list
D)A and B
E)None of these
Question
The ________ operation allows an item to be stored on a stack.

A)append
B)add
C)pop
D)push
E)None of these
Question
A stack has two primary operations:

A)push and pull
B)push and pop
C)insert and delete
D)append and delete
E)None of these
Question
A static queue can be implemented as a ________.

A)circular array
B)stack
C)dynamic linked list
D)dynamic vector
E)None of these
Question
This is a double-ended queue.

A)two-headed stack
B)two-tailed vector
C)circular array
D)deque
E)None of these
Question
Static stacks have a ________ size, and are implemented as ________.

A)fixed, linked lists
B)variable, arrays
C)fixed, arrays
D)variable, linked lists
E)None of these
Question
This is a container that provides quick access to elements at the front and the back of the list.

A)stack
B)queue
C)deque
D)All of these
E)None of these
Question
A(n)________ is an abstract data type that stores and retrieves items in a last-in-first-out manner.

A)array
B)queue
C)stack
D)vector
E)None of these
Question
________ queues are more intuitive and easier to understand than ________ queues.

A)Static, dynamic
B)Dynamic, static
C)Deque-like, stack-like
D)Stack-like, deque-like
E)None of these
Question
Stacks are useful data structures for algorithms that work ________ with the ________ saved element in the series.

A)last, first
B)first, last
C)efficiently, first
D)efficiently, last
E)None of these
Question
The ________ operation allows an item to be removed from a stack.

A)push
B)pop
C)delete
D)remove
E)None of these
Question
A queue is a data structure that stores and retrieves items in this manner.

A)last in, first out
B)first in, first out
C)first in, last out
D)random
E)None of these
Question
The queue data structure is commonly applied in connection with:

A)managing the order of print jobs
B)communications software
C)operating systems
D)All of these
E)None of these
Question
A ________ stack or queue is built around the linked-list.

A)dynamic
B)static
C)deque-based
D)floating point
E)None of these
Question
The following statement: <strong>The following statement:   Indicates:</strong> A)a new stack of integers, implemented as a vector B)a new stack of integers, implemented as a deque C)a new stack named vector, implemented as integers D)a new vector named stack, implemented with integers E)None of these <div style=padding-top: 35px>
Indicates:

A)a new stack of integers, implemented as a vector
B)a new stack of integers, implemented as a deque
C)a new stack named vector, implemented as integers
D)a new vector named stack, implemented with integers
E)None of these
Question
Data structures that can dynamically store elements and can grow and shrink in size are:

A)stacks
B)queues
C)deques
D)All of these
E)None of these
Question
In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) <strong>In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.)   Assume that the dequeue function, called in lines 4, 5, and 6, stores the number removed from the queue in the value variable. What will the statement in line 7 display?</strong> A)0 B)1 C)2 D)None of these <div style=padding-top: 35px>
Assume that the dequeue function, called in lines 4, 5, and 6, stores the number removed from the queue in the value variable.
What will the statement in line 7 display?

A)0
B)1
C)2
D)None of these
Question
In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) <strong>In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.)   Assume that the pop function, called in lines 4, 5, and 6, stores the number popped from the stack in the value variable. What will the statement in line 7 display?</strong> A)0 B)1 C)2 D)None of these <div style=padding-top: 35px>
Assume that the pop function, called in lines 4, 5, and 6, stores the number popped from the stack in the value variable.
What will the statement in line 7 display?

A)0
B)1
C)2
D)None of these
Question
When an element is added to a queue, it is added to the rear. When an element is removed, it is removed from the ________.

A)rear
B)middle
C)front
D)All of these
E)None of these
Question
The STL provides containers for deque and queue.
Question
The first item placed onto a stack is always the last item removed from the stack.
Question
In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.)<strong>In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.)  Assume that the pop function, called in lines 4 and 6, stores the number popped from the stack in the value variable. What will the statement in line 7 display?</strong> A)0 B)1 C)2 D)3 E)None of these <div style=padding-top: 35px>
Assume that the pop function, called in lines 4 and 6, stores the number popped from the stack in the value variable.
What will the statement in line 7 display?

A)0
B)1
C)2
D)3
E)None of these
Question
The pop function in the stack template of the STL does not retrieve the value from the top of the stack.
Question
Endeque and deque are the two most common queue operations.
Question
In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) <strong>In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.)   Assume that the pop function, called in line 4, stores the number popped from the stack in the value variable. What will the statement in line 5 display?</strong> A)0 B)1 C)2 D)None of these <div style=padding-top: 35px>
Assume that the pop function, called in line 4, stores the number popped from the stack in the value variable.
What will the statement in line 5 display?

A)0
B)1
C)2
D)None of these
Question
A dynamic queue can be implemented as a ________.

A)dynamic linked list
B)fixed-length array
C)fixed-length circular array
D)All of these
E)None of these
Question
If data is transmitted faster than it can be processed, it can be held in a ________ for processing.

A)stack
B)queue
C)static array
D)static deque
E)None of these
Question
Queues that are implemented as arrays are called ________ queues.

A)dynamic
B)stack
C)static
D)deque
E)None of these
Question
In a dequeue operation, the element at the ________ of the queue is removed.

A)middle
B)front
C)declaration
D)mid-point
E)None of these
Question
In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) <strong>In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.)   Assume that the dequeue function, called in lines 4, and 6, stores the number removed from the queue in the value variable. What will the statement in line 7 display?</strong> A)0 B)1 C)2 D)3 E)None of these <div style=padding-top: 35px>
Assume that the dequeue function, called in lines 4, and 6, stores the number removed from the queue in the value variable.
What will the statement in line 7 display?

A)0
B)1
C)2
D)3
E)None of these
Question
In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) <strong>In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.)   Assume that the dequeue function, called in line 4, stores the number removed from the queue in the value variable. What will the statement in line 5 display?</strong> A)0 B)1 C)2 D)None of these <div style=padding-top: 35px>
Assume that the dequeue function, called in line 4, stores the number removed from the queue in the value variable.
What will the statement in line 5 display?

A)0
B)1
C)2
D)None of these
Question
A practical application of the stack data type in a computer system is:

A)storage of local variables
B)tracking nested loops
C)tracking nested function calls
D)All of these
E)None of these
Question
A stack can be adapted to store ________ data types.

A)all
B)only the built-in C++
C)only abstract
D)deque-like
E)None of these
Question
A dynamic stack starts as an empty linked list.
Question
The pop function in the stack template does not retrieve the value from the top of the stack. It merely removes it.
Question
A real-world example of the queue data structure can be seen in a stack of cafeteria trays, where the last tray pushed onto the stack is the first tray removed.
Question
The programmer must declare in advance the size of a dynamic stack or queue.
Question
When the program knows the exact contents of a list and can access any element on demand, the data structure is known as a stacked deque.
Question
Push and pop are the two most common queue operations.
Question
Stacks and queues can be implemented as arrays or linked lists.
Question
If you are using a compiler that is older than C++ 11, be sure to put spaces between the angled brackets that appear next to each other when defining a stack.
Question
A stack that is implemented as a linked list is known as a deque.
Question
In a static stack class, the constructor function can dynamically allocate memory for the stack array.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/47
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 18: Stacks and Queues
1
A ________ is processed in a manner similar to customers standing in a grocery check-out line-the first customer in line is the first served.

A)stack
B)vector
C)queue
D)All of these
E)None of these
queue
2
The Standard Template Library offers a stack template that may be implemented as a:

A)vector
B)deque
C)linked list
D)All of these
E)None of these
All of these
3
A dynamic stack has a ________ size, and is implemented as a(n)________.

A)variable, linked list
B)fixed, linked list
C)variable, array
D)fixed, array
E)None of these
variable, linked list
4
Two primary queue operations are:

A)push and pop
B)enqueue and dequeue
C)insert and delete
D)onqueue and offqueue
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
5
A dynamic stack may be implemented as a(n)________, and expand or shrink with each push or pop operation.

A)array
B)structure
C)linked list
D)A and B
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
6
The ________ operation allows an item to be stored on a stack.

A)append
B)add
C)pop
D)push
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
7
A stack has two primary operations:

A)push and pull
B)push and pop
C)insert and delete
D)append and delete
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
8
A static queue can be implemented as a ________.

A)circular array
B)stack
C)dynamic linked list
D)dynamic vector
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
9
This is a double-ended queue.

A)two-headed stack
B)two-tailed vector
C)circular array
D)deque
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
10
Static stacks have a ________ size, and are implemented as ________.

A)fixed, linked lists
B)variable, arrays
C)fixed, arrays
D)variable, linked lists
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
11
This is a container that provides quick access to elements at the front and the back of the list.

A)stack
B)queue
C)deque
D)All of these
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
12
A(n)________ is an abstract data type that stores and retrieves items in a last-in-first-out manner.

A)array
B)queue
C)stack
D)vector
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
13
________ queues are more intuitive and easier to understand than ________ queues.

A)Static, dynamic
B)Dynamic, static
C)Deque-like, stack-like
D)Stack-like, deque-like
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
14
Stacks are useful data structures for algorithms that work ________ with the ________ saved element in the series.

A)last, first
B)first, last
C)efficiently, first
D)efficiently, last
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
15
The ________ operation allows an item to be removed from a stack.

A)push
B)pop
C)delete
D)remove
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
16
A queue is a data structure that stores and retrieves items in this manner.

A)last in, first out
B)first in, first out
C)first in, last out
D)random
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
17
The queue data structure is commonly applied in connection with:

A)managing the order of print jobs
B)communications software
C)operating systems
D)All of these
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
18
A ________ stack or queue is built around the linked-list.

A)dynamic
B)static
C)deque-based
D)floating point
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
19
The following statement: <strong>The following statement:   Indicates:</strong> A)a new stack of integers, implemented as a vector B)a new stack of integers, implemented as a deque C)a new stack named vector, implemented as integers D)a new vector named stack, implemented with integers E)None of these
Indicates:

A)a new stack of integers, implemented as a vector
B)a new stack of integers, implemented as a deque
C)a new stack named vector, implemented as integers
D)a new vector named stack, implemented with integers
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
20
Data structures that can dynamically store elements and can grow and shrink in size are:

A)stacks
B)queues
C)deques
D)All of these
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
21
In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) <strong>In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.)   Assume that the dequeue function, called in lines 4, 5, and 6, stores the number removed from the queue in the value variable. What will the statement in line 7 display?</strong> A)0 B)1 C)2 D)None of these
Assume that the dequeue function, called in lines 4, 5, and 6, stores the number removed from the queue in the value variable.
What will the statement in line 7 display?

A)0
B)1
C)2
D)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
22
In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) <strong>In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.)   Assume that the pop function, called in lines 4, 5, and 6, stores the number popped from the stack in the value variable. What will the statement in line 7 display?</strong> A)0 B)1 C)2 D)None of these
Assume that the pop function, called in lines 4, 5, and 6, stores the number popped from the stack in the value variable.
What will the statement in line 7 display?

A)0
B)1
C)2
D)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
23
When an element is added to a queue, it is added to the rear. When an element is removed, it is removed from the ________.

A)rear
B)middle
C)front
D)All of these
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
24
The STL provides containers for deque and queue.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
25
The first item placed onto a stack is always the last item removed from the stack.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
26
In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.)<strong>In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.)  Assume that the pop function, called in lines 4 and 6, stores the number popped from the stack in the value variable. What will the statement in line 7 display?</strong> A)0 B)1 C)2 D)3 E)None of these
Assume that the pop function, called in lines 4 and 6, stores the number popped from the stack in the value variable.
What will the statement in line 7 display?

A)0
B)1
C)2
D)3
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
27
The pop function in the stack template of the STL does not retrieve the value from the top of the stack.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
28
Endeque and deque are the two most common queue operations.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
29
In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) <strong>In the following code, assume the myStack object is a stack that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.)   Assume that the pop function, called in line 4, stores the number popped from the stack in the value variable. What will the statement in line 5 display?</strong> A)0 B)1 C)2 D)None of these
Assume that the pop function, called in line 4, stores the number popped from the stack in the value variable.
What will the statement in line 5 display?

A)0
B)1
C)2
D)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
30
A dynamic queue can be implemented as a ________.

A)dynamic linked list
B)fixed-length array
C)fixed-length circular array
D)All of these
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
31
If data is transmitted faster than it can be processed, it can be held in a ________ for processing.

A)stack
B)queue
C)static array
D)static deque
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
32
Queues that are implemented as arrays are called ________ queues.

A)dynamic
B)stack
C)static
D)deque
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
33
In a dequeue operation, the element at the ________ of the queue is removed.

A)middle
B)front
C)declaration
D)mid-point
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
34
In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) <strong>In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.)   Assume that the dequeue function, called in lines 4, and 6, stores the number removed from the queue in the value variable. What will the statement in line 7 display?</strong> A)0 B)1 C)2 D)3 E)None of these
Assume that the dequeue function, called in lines 4, and 6, stores the number removed from the queue in the value variable.
What will the statement in line 7 display?

A)0
B)1
C)2
D)3
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
35
In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.) <strong>In the following code, assume the myQueue object is a queue that can hold integers, and that value is an int variable. (The lines are numbered for reference purposes.)   Assume that the dequeue function, called in line 4, stores the number removed from the queue in the value variable. What will the statement in line 5 display?</strong> A)0 B)1 C)2 D)None of these
Assume that the dequeue function, called in line 4, stores the number removed from the queue in the value variable.
What will the statement in line 5 display?

A)0
B)1
C)2
D)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
36
A practical application of the stack data type in a computer system is:

A)storage of local variables
B)tracking nested loops
C)tracking nested function calls
D)All of these
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
37
A stack can be adapted to store ________ data types.

A)all
B)only the built-in C++
C)only abstract
D)deque-like
E)None of these
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
38
A dynamic stack starts as an empty linked list.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
39
The pop function in the stack template does not retrieve the value from the top of the stack. It merely removes it.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
40
A real-world example of the queue data structure can be seen in a stack of cafeteria trays, where the last tray pushed onto the stack is the first tray removed.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
41
The programmer must declare in advance the size of a dynamic stack or queue.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
42
When the program knows the exact contents of a list and can access any element on demand, the data structure is known as a stacked deque.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
43
Push and pop are the two most common queue operations.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
44
Stacks and queues can be implemented as arrays or linked lists.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
45
If you are using a compiler that is older than C++ 11, be sure to put spaces between the angled brackets that appear next to each other when defining a stack.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
46
A stack that is implemented as a linked list is known as a deque.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
47
In a static stack class, the constructor function can dynamically allocate memory for the stack array.
Unlock Deck
Unlock for access to all 47 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 47 flashcards in this deck.