Deck 6: Stacks
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/24
Play
Full screen (f)
Deck 6: Stacks
1
A client of a list can access any element and can insert elements at any location.
True
2
In programming, a(n) __________ is a data structure with the property that only the top element of the stack is accessible.
stack
3
The storage policy of a stack is sometimes referred to as __________.
A) First-In, First-Out, or FIFO
B) First-In, Last-Out, or LILO
C) Last-In, First-Out, or LIFO
D) Last-in, Last-Out, or LILO
A) First-In, First-Out, or FIFO
B) First-In, Last-Out, or LILO
C) Last-In, First-Out, or LIFO
D) Last-in, Last-Out, or LILO
Last-In, First-Out, or LIFO
4
Which of the following is a stack operation?
A) front
B) top
C) insert
D) back
A) front
B) top
C) insert
D) back
Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck
5
Which string is output by the last line of the following instruction set?
My_stack.push("Last to arrive ");
My_stack.push("first to leave ");
My_stack.pop();
Cout << my_stack.top() << endl;
A) Last to arrive
B) Last to arrive first to leave
C) first to leave Last to arrive
D) first to leave
My_stack.push("Last to arrive ");
My_stack.push("first to leave ");
My_stack.pop();
Cout << my_stack.top() << endl;
A) Last to arrive
B) Last to arrive first to leave
C) first to leave Last to arrive
D) first to leave
Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck
6
A(n) __________ is a string that reads the same in either direction: left to right or right to left.
Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck
7
The code segment from build_reverse, a member function of Palindrome_Finder, has been incorrectly altered.
The line __________ replaces the error written into the code segment.
A) while (char_stack.empty())
B) result = char_stack.front();
C) result += char_stack.top();
D) char_stack.push();

A) while (char_stack.empty())
B) result = char_stack.front();
C) result += char_stack.top();
D) char_stack.push();
Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck
8
Complete the definition for the new function class CiLess_Than, which will be used to perform a case-sensitive comparison of characters.


Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck
9
An expression is __________ if each subexpression that starts with the symbol { ends with the symbol }, and the same statement is true for the other symbol pairs.
Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck
10
The expression
(w * [x + y) / z - [p / {r - q}])
Is not balanced, because the subexpression __________ is incorrect.
A) {r - q}
B) [x + y)
C) [p / {r - q}]
D) p / {r - q}
(w * [x + y) / z - [p / {r - q}])
Is not balanced, because the subexpression __________ is incorrect.
A) {r - q}
B) [x + y)
C) [p / {r - q}]
D) p / {r - q}
Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck
11
Suppose the function is_balanced in Paren_Checker.cpp is called with the expression
[ (x + y)/8 - z [ p * {r + q) ] ]
What is the value of s.top() in the return statement?
A) empty
B) [
C) ]
D) {
[ (x + y)/8 - z [ p * {r + q) ] ]
What is the value of s.top() in the return statement?
A) empty
B) [
C) ]
D) {
Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck
12
Within the standard library a stack can be implemented using a vector, list, or __________ as a component to hold the contents of the stack.
Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck
13
The stack is said to be a(n) __________ class because it adapts the functions available in another class to the interface its clients expect by giving different names to essentially the same operations.
Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck
14
It is easier to insert and remove from the middle of a linked list.
Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck
15
The C++ standard requires that implementations of sequential containers provide push_back, pop_back, and back operations in (amortized) constant time.
Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck
16
Normally we write expressions using __________ notation, in which binary operators (*, +, and so forth) are inserted between their operands.
Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck
17
A calculator (or computer) normally scans an expression string from right to left.
Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck
18
The advantage of the __________ form is that there is no need to group subexpressions in parentheses or even to consider operator precedence.
A) infix
B) suffix
C) postfix
D) adfix
A) infix
B) suffix
C) postfix
D) adfix
Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck
19
In a(n) __________expression the operands precede the operators.
Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck
20
The __________ function (member of the istream class) is used to "unread" a single character.
Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck
21
According to the __________ rule, operators with the same precedence are evaluated in left-to-right order.
Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck
22
Using the algorithm for converting an infix expression to a postfix expression, how is
(14 + 5) - 8 * 4 / 2
Represented in postfix form?
A) 14 5 8 4 2 + - * /
B) 14 5 + 8 4 * 2 / -
C) 14 5 + 8 * / 2 -
D) 14 5 8 + - 2 * /
(14 + 5) - 8 * 4 / 2
Represented in postfix form?
A) 14 5 8 4 2 + - * /
B) 14 5 + 8 4 * 2 / -
C) 14 5 + 8 * / 2 -
D) 14 5 8 + - 2 * /
Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck
23
The action of using function top to access an item at the top of the stack, without removing it, is sometimes called __________ the stack.
A) peeking
B) skimming
C) popping
D) peeling
A) peeking
B) skimming
C) popping
D) peeling
Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck
24
__________ are used to separate an expression into subexpressions.
A) Tokens
B) Operators
C) Operands
D) Parentheses
A) Tokens
B) Operators
C) Operands
D) Parentheses
Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck