Chapter 18 Flashcards

1
Q

True or false:
The bottom element of the stack is the last element added to the stack.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or false:
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.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

True or false:
If you try to add a new item to a full stack, the resulting condition is called an outflow.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

True or false:
In the linked implementation of stacks, the memory to store the stack elements is allocated statically.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

True or false:
The default constructor for the linked implementation of a stack initializes the stack to an empty state when a stack
object is declared.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

True or false:
Postfix notation requires the use of parentheses to enforce operator precedence.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

True or false:
The infix expression
(a + b) * (c - d / e) + f
is equivalent to the postfix expression
ab + cde /-* f +

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

True or false:
The expression a + b is the same in both infix notation and postfix notation.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

True or false:
A queue is a First In First Out(FIFO) data structure.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

A(n) ____ is a list of homogenous elements in which the addition and deletion of elements occurs only at one end.

A

stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

The addition and deletion of elements of a stack occurs only at the ____ of the stack.

A

Top

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

The ____ element of the stack is the last element added to the stack.

A

top

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

A stack is a(n) ____ data structure.

A

LIFO(Last In First Out)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

You can perform the add operation, called ____, to add an element onto the stack.

A

push

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

You can perform the operation ____ to remove the top element from the stack.

A

pop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

A stack can be implemented as either a(n) ____ or a linked structure.

A

array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

When a stack is implemented as an array, the array is empty if the value of stackTop is ____.

A

zero

18
Q

If you try to add a new item to a full stack, the resulting condition is called a(n) ____.

A

overflow

19
Q

Popping an element from an empty stack is called ____.

A

underflow

20
Q

What is the output of the following code?

stackType<int> 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;</int>

A

x = 11
y = 6

21
Q

The following expression (a - b) * (c + d) is equivalent to which of the following postfix expressions?

A

a b - c d + *

22
Q

The postfix expression 5 6 + 4 * 10 5 / - = evaluates to ____.

A

42

23
Q

The postfix expression 2 4 6 * + 15 - 21 7 / + = evaluates to ____.

A

14

24
Q

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

one

25
Q

The postfix expression 3 5 + 2 ; 6 - = will generate an error, because it ____.

A

contains an illegal operator

26
Q

The postfix expression 14 2 5 + = will generate an error, because ____.

A

there will be too many elements in the stack when the equal sign is encountered

27
Q

A queue is a data structure in which the elements are ____.

A

added to the rear and deleted from the front

28
Q

Which of the following is listed in the chapter as a basic operation performed on a queue?

A

isEmptyQueue

29
Q

What is the output of the following code?

queueType<int> 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;</int>

A

x = 2
y = 3

30
Q

What is the output of the following code?

queueType<int> 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</int>

A

6 4 2 3

31
Q

A technique in which one system models the behavior of another system is called ____.

A

simulation

32
Q

To describe a queuing system, we use the term ____ for the object that provides the service.

A

server

33
Q

To describe a queuing system, we use the term ____ for the object receiving the service.

A

customer

34
Q

The elements at the ____________________ of the stack have been in the stack the longest.

A

bottom

35
Q

An array is a(n) ____________________ access data structure.

A

random

36
Q

In the array representation of a stack, the stack is initialized simply by setting stackTop to
____________________.

A

zero(0)

37
Q

The ____________________ constructor is called when a stack object is passed as a (value) parameter to a
function.

A

copy

38
Q

In ____________________ notation, operators are written after the operands.

A

postfix

39
Q

____________________ techniques are used when it is too expensive or dangerous to experiment with real
systems.

A

simulation

40
Q

When describing a queuing system, we use the term ____________________ to refer to the time it takes to serve
a customer.

A

transaction time

41
Q

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 1.

A

time-driven

42
Q

In a queuing system, every customer has a customer number, arrival time, ____________________ time,
transaction time, and departure time.

A

waiting