Lab: Questions About Stacks and Queues
Instructions:
Answer as many of the following questions as you can during the lab period.
If you are unable to complete the assignment during the lab period it
is strongly recommended that you complete it on your own.
You must submit hardcopy of your answers by 5:00PM
(on the day of the lab).
Getting Ready:
Before going any further, you should:
-
Make a directory for this lab.
-
Setup your development environment.
-
Download the following files:
to your working directory. (In most browsers, the easiest
way to do this is by right-clicking on each of the links above.)
1. 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);
2. 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.]