Lab: Questions About Stacks and Queues
1 Instructions:
Answer as many of the following questions as you can during the lab period.
You must submit hardcopy of the memory diagrams (they may be hand drawn).
Your hardcopy submission must include your full name and email address
at the top.
If you are unable to complete the assignment during the lab period it
is strongly recommended that you complete it on your own.
3 Basics:
This part of the lab will help you determine whether you understand
some of the basic issues involving linked data structures.
-
Draw a model of an
IntNode
that contains the
value 5.
-
Draw a model of a
Node
that contains a reference to
a String
containing "JMU".
-
Draw a model of what memory looks like after the following
is executed:
Pile pile;
pile = new Pile();
-
Continuing with this same example, now draw a model of what memory
looks like after the following is executed:
pile.push(10);
-
Continuing with this same example, now draw a model of what memory
looks like after the following is executed:
pile.push(20);
-
Continuing with this same example, now draw a model of what memory
looks like after the following is executed:
pile.push(30);
4 More Complicated Linked Structures:
This part of the lab will help you determine whether you understand
more complicated linked data structures.
-
Draw a model of what memory looks like after the following
is executed:
Quack quack;
quack = new Quack();
-
Continuing with this same example, now draw a model of what memory
looks like after the following is executed:
quack.push("I");
-
Continuing with this same example, now draw a model of what memory
looks like after the following is executed:
quack.push("like");
-
Continuing with this same example, now draw a model of what memory
looks like after the following is executed:
quack.push("ducks");
-
Continuing with this same example, now draw a model of what memory
looks like after the following is executed:
quack.pep();
-
Continuing with this same example, now draw a model of what memory
looks like after the following is executed:
quack.pep();
-
Continuing with this same example, now draw a model of what memory
looks like after the following is executed:
quack.pep();
-
Trace the execution of the
main()
method in the
QuackDriver
class. [Note: This example uses the
pip()
method in the Quack
class, not the
pep()
method.]