Deck 17: Stacks and Queues

Full screen (f)
exit full mode
Question
If you try to add a new item to a full stack,the resulting condition is called an outflow.
Use Space or
up arrow
down arrow
to flip the card.
Question
The bottom element of the stack is the last element added to the stack.
Question
A queue is a First In First Out data structure.
Question
A stack is a(n)____ data structure.

A) FIFO
B) FILO
C) LIFO
D) LILO
Question
Postfix notation requires the use of parentheses to enforce operator precedence.
Question
The default constructor for the linked implementation of a stack initializes the stack to an empty state when a stack object is declared.
Question
You can perform the add operation,called ____,to add an element onto the stack.

A) pop
B) push
C) enqueue
D) dequeue
Question
Popping an element from an empty stack is called ____.

A) overflow
B) underflow
C) exception
D) overloading
Question
In the array representation of a stack,an unlimited number of elements can be pushed onto the stack.
Question
When a stack is implemented as an array,the array is empty if the value of stackTop is ____.

A) zero
B) one
C) nonzero
D) equal to the size of the array
Question
A stack can be implemented as either an array or a(n)____ structure.

A) mapped
B) nested
C) queued
D) linked
Question
The infix expression
(a + b)* (c - d / e)+ f
is equivalent to the postfix expression
ab + cde /-* f +
Question
The ____ element of the stack is the last element added to the stack.

A) top
B) bottom
C) head
D) tail
Question
If you try to add a new item to a full stack,the resulting condition is called a(n)____.

A) override
B) overflow
C) overload
D) underflow
Question
A(n)____ is a list of homogenous elements in which the addition and deletion of elements occurs only at one end.

A) stack
B) queue
C) array
D) linked list
Question
The addition and deletion of elements of the stack occurs only at the ____ of the stack.

A) head
B) bottom
C) top
D) middle
Question
You can perform the operation ____ to remove the top element from the stack.

A) dequeue
B) top
C) pop
D) push
Question
In the array representation of a stack,if a value called stackTop indicates the number of elements in the stack,then stackTop-1 points to the top item of the stack.
Question
In the linked implementation of stacks,the memory to store the stack elements is allocated statically.
Question
The expression a + b is the same in both infix notation and postfix notation.
Question
An array is a(n)____________________ access data structure.
Question
In the array representation of a stack,the stack is initialized simply by setting stackTop to ____________________.
Question
Which of the following is a basic operation performed on a queue?

A) push
B) pop
C) isEmptyQueue
D) top
Question
The expression (a - b)* (c + d)is equivalent to which of the following postfix expressions?

A) a b c d - + *
B) a b - c d + *
C) a b - + c d *
D) - + * a b c d
Question
What is the output of the following code? queueType queue;
Int x,y;
X = 2;
Y = 6;
Queue.addQueue(x);
Queue.addQueue(y);
X = queue.front();
Queue.deleteQueue();
Queue.addQueue(x + 2);
Queue.addQueue(x);
Queue.addQueue(y - 3);
While (!queue.isEmptyQueue())
{
Cout << queue.front()<< " ";
Queue.deleteQueue();
}
Cout << endl;

A) 6 2 3 3
B) 6 2 4 2
C) 6 3 3 3
D) 6 4 2 3
Question
A technique in which one system models the behavior of another system is called ____.

A) imitation
B) recursion
C) simulation
D) stimulation
Question
In evaluating a postfix expression,when an equal sign (=)is encountered,how many elements must the stack contain so that no error is generated?

A) none
B) one
C) two
D) three
Question
What is the output of the following code? queueType queue;
Int x,y;
X = 2;
Y = 3;
Queue.addQueue(x);
Queue.addQueue(y);
X = queue.front();
Queue.deleteQueue();
Queue.addQueue(x + 2);
Queue.addQueue(x);
Queue.addQueue(y - 3);
Y = queue.front();
Queue.deleteQueue();
Cout << "x = " << x << endl;
Cout << "y = " << y << endl;

A) x = 2
Y = 4
B) x = 4
Y = 3
C) x = 2
Y = 3
D) x = 3
Y = 2
Question
The postfix expression 14 2 5 + = will generate an error,because ____.

A) it contains an illegal operator
B) it does not have enough operands
C) it has too many operators
D) there will be too many elements in the stack when the equal sign is encountered
Question
To describe a queuing system,we use the term ____ for the object receiving the service.

A) client
B) server
C) customer
D) provider
Question
In the linked implementation of stacks,the stack is ____________________ only if you run out of memory space.
Question
The postfix expression 3 5 + 2 ; 6 - = will generate an error,because it ____.

A) contains an illegal operator
B) does not have enough operands
C) has too many operands
D) has too many operators
Question
To describe a queuing system,we use the term ____ for the object that provides the service.

A) client
B) server
C) customer
D) provider
Question
A queue is a data structure in which the elements are ____.

A) added to the rear and deleted from the front
B) added to and deleted from the rear
C) added to and deleted from the front
D) added and deleted in the middle
Question
The elements at the ____________________ of a stack have been in the stack the longest.
Question
What is the output of the following code? stackType stack;
Int x,y;
X = 5;
Y = 3;
Stack.push(4);
Stack.push(x);
Stack.push(x + 1);
Y = stack.top();
Stack.pop();
Stack.push(x + y);
X = stack.top();
Stack.pop();
Cout << "x = " << x << endl;
Cout << "y = " << y << endl;

A) x = 5
Y = 6
B) x = 4
Y = 3
C) x = 5
Y = 3
D) x = 11
Y = 6
Question
What is the output of the following code? stackType stack;
Int x,y;
X = 4;
Y = 2;
Stack.push(6);
Stack.push(x);
Stack.push(x + 1);
Y = stack.top();
Stack.pop();
Stack.push(x + y);
X = stack.top();
Stack.pop();
Cout << "x = " << x << endl;

A) x = 4
B) x = 5
C) x = 6
D) x = 9
Question
The ____________________ constructor is called when a stack object is passed as a (value)parameter to a function.
Question
The postfix expression 5 6 + 4 * 10 5 / - = evaluates to ____.

A) 10
B) 30
C) 42
D) 44
Question
The postfix expression 2 4 6 * + 15 - 21 7 / + = evaluates to ____.

A) 4
B) 14
C) 24
D) 26
Question
A(n)____________________ system consists of servers and queues of objects waiting to be served.
Question
In a queuing system,every customer has a customer number,arrival time,____________________ time,transaction time,and departure time.
Question
In a(n)____________________ array,the first array position immediately follows the last array position.
Question
In a queuing system,we use a(n)____________________ variable to set the status of the server.
Question
In the late 1950s,the Australian philosopher and early computer scientist Charles L.Hamblin proposed a scheme in which the operators follow the operands (postfix operators),resulting in the ____________________ notation.
Question
In ____________________ notation,operators are written after the operands.
Question
In a(n)____________________ simulation,the clock is implemented as a counter,and the passage of,say,one minute can be implemented by incrementing the counter by one.
Question
When describing a queuing system,we use the term ____________________ time to refer to the time it takes to serve a customer.
Question
____________________ techniques are used when it is too expensive or dangerous to experiment with real systems.
Question
The ____________________ elements of a stack and queue should not be accessed directly.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/50
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 17: Stacks and Queues
1
If you try to add a new item to a full stack,the resulting condition is called an outflow.
False
2
The bottom element of the stack is the last element added to the stack.
False
3
A queue is a First In First Out data structure.
True
4
A stack is a(n)____ data structure.

A) FIFO
B) FILO
C) LIFO
D) LILO
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
5
Postfix notation requires the use of parentheses to enforce operator precedence.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
6
The default constructor for the linked implementation of a stack initializes the stack to an empty state when a stack object is declared.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
7
You can perform the add operation,called ____,to add an element onto the stack.

A) pop
B) push
C) enqueue
D) dequeue
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
8
Popping an element from an empty stack is called ____.

A) overflow
B) underflow
C) exception
D) overloading
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
9
In the array representation of a stack,an unlimited number of elements can be pushed onto the stack.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
10
When a stack is implemented as an array,the array is empty if the value of stackTop is ____.

A) zero
B) one
C) nonzero
D) equal to the size of the array
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
11
A stack can be implemented as either an array or a(n)____ structure.

A) mapped
B) nested
C) queued
D) linked
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
12
The infix expression
(a + b)* (c - d / e)+ f
is equivalent to the postfix expression
ab + cde /-* f +
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
13
The ____ element of the stack is the last element added to the stack.

A) top
B) bottom
C) head
D) tail
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
14
If you try to add a new item to a full stack,the resulting condition is called a(n)____.

A) override
B) overflow
C) overload
D) underflow
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
15
A(n)____ is a list of homogenous elements in which the addition and deletion of elements occurs only at one end.

A) stack
B) queue
C) array
D) linked list
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
16
The addition and deletion of elements of the stack occurs only at the ____ of the stack.

A) head
B) bottom
C) top
D) middle
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
17
You can perform the operation ____ to remove the top element from the stack.

A) dequeue
B) top
C) pop
D) push
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
18
In the array representation of a stack,if a value called stackTop indicates the number of elements in the stack,then stackTop-1 points to the top item of the stack.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
19
In the linked implementation of stacks,the memory to store the stack elements is allocated statically.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
20
The expression a + b is the same in both infix notation and postfix notation.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
21
An array is a(n)____________________ access data structure.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
22
In the array representation of a stack,the stack is initialized simply by setting stackTop to ____________________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following is a basic operation performed on a queue?

A) push
B) pop
C) isEmptyQueue
D) top
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
24
The expression (a - b)* (c + d)is equivalent to which of the following postfix expressions?

A) a b c d - + *
B) a b - c d + *
C) a b - + c d *
D) - + * a b c d
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
25
What is the output of the following code? queueType queue;
Int x,y;
X = 2;
Y = 6;
Queue.addQueue(x);
Queue.addQueue(y);
X = queue.front();
Queue.deleteQueue();
Queue.addQueue(x + 2);
Queue.addQueue(x);
Queue.addQueue(y - 3);
While (!queue.isEmptyQueue())
{
Cout << queue.front()<< " ";
Queue.deleteQueue();
}
Cout << endl;

A) 6 2 3 3
B) 6 2 4 2
C) 6 3 3 3
D) 6 4 2 3
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
26
A technique in which one system models the behavior of another system is called ____.

A) imitation
B) recursion
C) simulation
D) stimulation
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
27
In evaluating a postfix expression,when an equal sign (=)is encountered,how many elements must the stack contain so that no error is generated?

A) none
B) one
C) two
D) three
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
28
What is the output of the following code? queueType queue;
Int x,y;
X = 2;
Y = 3;
Queue.addQueue(x);
Queue.addQueue(y);
X = queue.front();
Queue.deleteQueue();
Queue.addQueue(x + 2);
Queue.addQueue(x);
Queue.addQueue(y - 3);
Y = queue.front();
Queue.deleteQueue();
Cout << "x = " << x << endl;
Cout << "y = " << y << endl;

A) x = 2
Y = 4
B) x = 4
Y = 3
C) x = 2
Y = 3
D) x = 3
Y = 2
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
29
The postfix expression 14 2 5 + = will generate an error,because ____.

A) it contains an illegal operator
B) it does not have enough operands
C) it has too many operators
D) there will be too many elements in the stack when the equal sign is encountered
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
30
To describe a queuing system,we use the term ____ for the object receiving the service.

A) client
B) server
C) customer
D) provider
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
31
In the linked implementation of stacks,the stack is ____________________ only if you run out of memory space.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
32
The postfix expression 3 5 + 2 ; 6 - = will generate an error,because it ____.

A) contains an illegal operator
B) does not have enough operands
C) has too many operands
D) has too many operators
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
33
To describe a queuing system,we use the term ____ for the object that provides the service.

A) client
B) server
C) customer
D) provider
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
34
A queue is a data structure in which the elements are ____.

A) added to the rear and deleted from the front
B) added to and deleted from the rear
C) added to and deleted from the front
D) added and deleted in the middle
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
35
The elements at the ____________________ of a stack have been in the stack the longest.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
36
What is the output of the following code? stackType stack;
Int x,y;
X = 5;
Y = 3;
Stack.push(4);
Stack.push(x);
Stack.push(x + 1);
Y = stack.top();
Stack.pop();
Stack.push(x + y);
X = stack.top();
Stack.pop();
Cout << "x = " << x << endl;
Cout << "y = " << y << endl;

A) x = 5
Y = 6
B) x = 4
Y = 3
C) x = 5
Y = 3
D) x = 11
Y = 6
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
37
What is the output of the following code? stackType stack;
Int x,y;
X = 4;
Y = 2;
Stack.push(6);
Stack.push(x);
Stack.push(x + 1);
Y = stack.top();
Stack.pop();
Stack.push(x + y);
X = stack.top();
Stack.pop();
Cout << "x = " << x << endl;

A) x = 4
B) x = 5
C) x = 6
D) x = 9
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
38
The ____________________ constructor is called when a stack object is passed as a (value)parameter to a function.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
39
The postfix expression 5 6 + 4 * 10 5 / - = evaluates to ____.

A) 10
B) 30
C) 42
D) 44
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
40
The postfix expression 2 4 6 * + 15 - 21 7 / + = evaluates to ____.

A) 4
B) 14
C) 24
D) 26
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
41
A(n)____________________ system consists of servers and queues of objects waiting to be served.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
42
In a queuing system,every customer has a customer number,arrival time,____________________ time,transaction time,and departure time.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
43
In a(n)____________________ array,the first array position immediately follows the last array position.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
44
In a queuing system,we use a(n)____________________ variable to set the status of the server.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
45
In the late 1950s,the Australian philosopher and early computer scientist Charles L.Hamblin proposed a scheme in which the operators follow the operands (postfix operators),resulting in the ____________________ notation.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
46
In ____________________ notation,operators are written after the operands.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
47
In a(n)____________________ simulation,the clock is implemented as a counter,and the passage of,say,one minute can be implemented by incrementing the counter by one.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
48
When describing a queuing system,we use the term ____________________ time to refer to the time it takes to serve a customer.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
49
____________________ techniques are used when it is too expensive or dangerous to experiment with real systems.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
50
The ____________________ elements of a stack and queue should not be accessed directly.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 50 flashcards in this deck.