E-Mail Help Policies Solutions Study-Aids Syllabus Tools
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.

2 Getting Ready: Before going any further you should:
  1. Make a directory for this lab.
  2. Setup your development environment.
  3. Download the following files:

    IntNode.java
    Pile.java
    Node.java
    Quack.java
    QuackDriver.java

    to your working directory.

  4. Familiarize yourself with these classes.
3 Basics: This part of the lab will help you determine whether you understand some of the basic issues involving linked data structures.
  1. Draw a model of an IntNode that contains the value 5.

  2. Draw a model of a Node that contains a reference to a String containing "JMU".

  3. Draw a model of what memory looks like after the following is executed:
        Pile            pile;
      
        pile = new Pile();
        

  4. Continuing with this same example, now draw a model of what memory looks like after the following is executed:
        pile.push(10);
        

  5. Continuing with this same example, now draw a model of what memory looks like after the following is executed:
        pile.push(20);
        

  6. 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.
  1. Draw a model of what memory looks like after the following is executed:
        Quack            quack;
      
        quack = new Quack();
        

  2. Continuing with this same example, now draw a model of what memory looks like after the following is executed:
        quack.push("I");
        

  3. Continuing with this same example, now draw a model of what memory looks like after the following is executed:
        quack.push("like");
        

  4. Continuing with this same example, now draw a model of what memory looks like after the following is executed:
        quack.push("ducks");
        

  5. Continuing with this same example, now draw a model of what memory looks like after the following is executed:
        quack.pep();
        

  6. Continuing with this same example, now draw a model of what memory looks like after the following is executed:
        quack.pep();
        

  7. Continuing with this same example, now draw a model of what memory looks like after the following is executed:
        quack.pep();
        

  8. 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.]

Copyright 2006