CS 221
Advanced Programming

Implementations of the Stack ADT (Rance Harmon)

We started out by going over the linked list implementation of a stack.We discussed how to represent the pointers (references) and Nodes, and then students were asked to make drawings on paper for a sequence of Stack operations. We then went through the operations with drawings on the board, so all could check their drawings.

We also discussed two ways to deal with the Node class's private instance variables. First,we just changed them to public. We discussed why this was not the best way to do it. Then we examined how to make the Node class a private inner class, leaving the instance variables private (the textbook does it that way).

We then got well along in implementing a stack as an ArrayList. We began with the example of the stack implemented with an a simple int array, from the lab on the previous Tuesday. Then we went through each line and changed the code from the array to the ArrayList implementation, referring to the ArrayList API.