Deck 6: Stacks

Full screen (f)
exit full mode
Question
A client of a list can access any element and can insert elements at any location.
Use Space or
up arrow
down arrow
to flip the card.
Question
In programming, a(n) __________ is a data structure with the property that only the top element of the stack is accessible.
Question
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
Question
Which of the following is a stack operation?

A) front
B) top
C) insert
D) back
Question
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
Question
A(n) __________ is a string that reads the same in either direction: left to right or right to left.
Question
The code segment from build_reverse, a member function of Palindrome_Finder, has been incorrectly altered.
<strong>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.</strong> A) while (char_stack.empty()) B) result = char_stack.front(); C) result += char_stack.top(); D) char_stack.push(); <div style=padding-top: 35px> 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();
Question
Complete the definition for the new function class CiLess_Than, which will be used to perform a case-sensitive comparison of characters.
Complete the definition for the new function class CiLess_Than, which will be used to perform a case-sensitive comparison of characters.  <div style=padding-top: 35px>
Question
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.
Question
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}
Question
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) {
Question
Within the standard library a stack can be implemented using a vector, list, or __________ as a component to hold the contents of the stack.
Question
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.
Question
It is easier to insert and remove from the middle of a linked list.
Question
The C++ standard requires that implementations of sequential containers provide push_back, pop_back, and back operations in (amortized) constant time.
Question
Normally we write expressions using __________ notation, in which binary operators (*, +, and so forth) are inserted between their operands.
Question
A calculator (or computer) normally scans an expression string from right to left.
Question
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
Question
In a(n) __________expression the operands precede the operators.
Question
The __________ function (member of the istream class) is used to "unread" a single character.
Question
According to the __________ rule, operators with the same precedence are evaluated in left-to-right order.
Question
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 * /
Question
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
Question
__________ are used to separate an expression into subexpressions.

A) Tokens
B) Operators
C) Operands
D) Parentheses
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/24
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
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
Last-In, First-Out, or LIFO
4
Which of the following is a stack operation?

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
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.
<strong>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.</strong> A) while (char_stack.empty()) B) result = char_stack.front(); C) result += char_stack.top(); D) char_stack.push(); 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();
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.
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}
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) {
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
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 * /
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
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
Unlock Deck
Unlock for access to all 24 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 24 flashcards in this deck.