Unlock access to all the studying documents.
View Full Document
Copyright Cengage Learning. Powered by Cognero.
1. The bottom element of the stack is the last element added to the stack.
2. 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.
3. If you try to add a new item to a full stack, the resulting condition is called an outflow.
4. In the linked implementation of stacks, the memory to store the stack elements is allocated statically.
Copyright Cengage Learning. Powered by Cognero.
9. A queue is a First In First Out data structure.
10. A(n) ____ is a list of homogenous elements in which the addition and deletion of elements occurs only at one end.
11. The addition and deletion of elements of a stack occurs only at the ____ of the stack.
12. The ____ element of the stack is the last element added to the stack.
Copyright Cengage Learning. Powered by Cognero.
13. A stack is a(n) ____ data structure.
14. You can perform the add operation, called ____, to add an element onto the stack.
15. You can perform the operation ____ to remove the top element from the stack.
Copyright Cengage Learning. Powered by Cognero.
16. A stack can be implemented as either a(n) ____ or a linked structure.
17. When a stack is implemented as an array, the array is empty if the value of stackTop is ____.
equal to the size of the array
18. If you try to add a new item to a full stack, the resulting condition is called a(n) ____.
19. Popping an element from an empty stack is called ____.
Copyright Cengage Learning. Powered by Cognero.
20. 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;
21. The following expression (a – b) * (c + d) is equivalent to which of the following postfix expressions?
22. The postfix expression 5 6 + 4 * 10 5 / – = evaluates to ____.
Copyright Cengage Learning. Powered by Cognero.
it does not have enough operands
it has too many operators
there will be too many elements in the stack when the equal sign is encountered
27. A queue is a data structure in which the elements are ____.
added to the rear and deleted from the front
added to and deleted from the rear
added to and deleted from the front
added and deleted in the middle
28. Which of the following is listed in the chapter as a basic operation performed on a queue?
29. What is the output of the following code?
queueType<int> queue;
int x, y;
x = 2;
y = 3;
queue.addQueue(x);
queue.addQueue(y);
Copyright Cengage Learning. Powered by Cognero.
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;
30. 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