SA-6, due Apr 26

Exercises

  1. Consider the following operations on an initially empty stack s:
    s.push("a");
    s.push("b");
    s.pop();
    s.push("c");
    s.pop();
    s.pop();
    1. Draw a mathematical / abstract state of the stack after each operation (i.e., without reference to any kind of implementation). For example, treating "bottom" as left (indicated by "["):
      [1,2,3
    2. Draw the concrete state of an SLLStack after each operation (i.e., the head and linked structure). For example,
      head->"x"->"y"->"z"->[/]
  2. Consider the following operations on an initially empty queue q:
    q.enqueue("a");
    q.enqueue("b");
    q.dequeue();
    q.enqueue("c");
    q.dequeue(); 
    q.dequeue(); 
    1. Draw a mathematical / abstract state of the queue after each operation (i.e., without reference to any kind of implementation). For example, treating "front" as left, and using angle brackets to indicate that there's an explicit order from left to right:
      <1,2,3>
    2. Draw the concrete state of an SLLQueue after each operation (i.e., the head, tail, and linked structure). For example,
      head->"x"->"y"->"z"->[/]
                       ^
                       |
                      tail

Submission Instructions

You will be graded on the technical correctness of your drawing, not the beauty (as long as it's sufficiently clear). So you may draw on paper or with a drawing program or with a word processor (in which case it's fine to just write text with "->", etc., as above). Either way, the submission is still electronic, so if you draw on paper than scan it in or take a respectable picture with your phone.