Corrections in green added 5 November 2011.
Correction in brown added 6 November 2011.
remove
operation throws an
ElementNotFoundException
, assume that this exception is
caught immediately and the the catch code does nothing. (So, in
effect, the remove
becomes like the poll
method in the Java library Queue
interface.)
ArrayList
and LinkedList
, not the
java.util
ones.
ArrayList
class called head
and tail
. They mean
front
and rear
-- there is no
front
in the code, but as they say on page 153, the
"front" location in this implementation is always 0. So you should
say when rear
can be 0.
LinkedList
class and implements their
StackADT
interface.
sum(i, j)
to be equal to i if i = j, and otherwise to
sum(i, k) + sum (k+1, j)
, where k is the number (i+j)/2 (where
"/" is Java integer division, rounding down). (This
used to erroreously say "(1+j)/2".) You may assume that neither i
nor j is negative. Trace the calculation of sum(1, 7)
.
Last modified 6 November 2011