Sep 9

Lecture Overview

Today I talked about ArrayQueue and ArrayDeque. They are both based on the trick of using modular arithmetic to simulate a circular array. The ArrayQueue is a warmup since it just implements the FIFO Queue ADT, while the ArrayDeque extends this to implement the list ADT. The names of these things aren't clear, just remember they are using the same technique to implement different ADTs.

(There is a typo in the statement of Theorem 2..2: it should say add(x) and remove() instead of add(i,x) and remove(i), since in ArrayQueues there is no i.)

Exercises

On Day 4, you wrote pseudocode for an add_all operation for ArrayStacks. Modify my arraystack.cpp implementation to include the add_all operation based on your pseudocode. That is, to the StringArrayStack structure, add a function

void add_all(int i, StringArrayStack &source) {

}

Note how I pass the source as a reference. Also, update the main function to test out your implementation of add_all.