You may work individually or in pairs.
General requirements:
pop
, push
, peek
,
and empty
for this problem.new
to create new stacks.
Write a method that takes a stack of Integers and creates and returns
a copy of this stack, i.e. a stack that has the exact same elements in
the same order. The given stack must be unchanged when the method is
finished (make sure to print it out at the end to check this
condition). Please include your test
data when submitting the program (it may be commented out).
Hint: think of additional storage that you need for this task.
Write a method that takes two stack of Integers and returns "true"
when the two stacks contain the same elements in the same order and
"false" otherwise. The two stacks must be in the original order when
the method finishes (regardless of whether the stacks were the same or
not). You might want to write a recursive function for this problem,
but you don't have to.
Important: the program must work without a run-time error (for instance,
when one of the stacks is empty and the other one is not, it should return
"false"). Carefully handle all cases when one stack has fewer
elements than the other one.
Please submit all of your test data.
Submit your Java file(s) to me by e-mail. The subject must be Problem Set N, where N is the problem set number. If working in a group, CC your group partner.