EX 3.5 Given the resulting stack X from the previous exercise, what would be the
result of each of the following?
Y = X.peek();
The value of Y would be 9 and the stack would remain unchanged.
EX 3.6 What should be the time complexity of the isEmpty(), size(), and toString()
methods?
Using the count variable, the size method is O(1) and simply returns the value of count.
EX 3.7 Show how the undo operation in a word processor can be supported by the
use of a stack. Give specific examples and draw the contents of the stack after
various actions are taken.
Suppose the following actions were taken, in order, in the word processor: (1) type the
title, (2) make the title bold, (3) delete the third paragraph, and (4) center the author’s
EX 3.8 In the postfix expression evaluation example, the two most re- cent operands
are popped when an operator is encountered so that the sub-expression can
be evaluated. The first operand popped is treated as the second operand in the
sub-expression, and the second operand popped is the first. Give and explain
an example that demonstrates the importance of this aspect of the solution.
For operations such as addition and multiplication, the order of operands does not
matter, but for subtraction and division, for instance they do. So the postfix expression