2. Unlimited Stack

Write a class ArrayStack representing a array-based stack that can grow to any size. Use your DynArray implementation that we wrote last week. Implement this interface:

interface Stack {
  void push(int i);
  int pop();
  bool isEmpty { get; }
}

4. Two-Stack Queue

Write a class TwoStackQueue that implements a queue. Implement this interface:

interface Queue {
  void enqueue(int i);
  int dequeue();
  bool isEmpty { get; }
}

Your class should have a constructor that takes two stacks, i.e. objects that implement the Stack interface above. It should use those stacks to implement the queue.

5. Linked List Using Recursion

Write a class that holds a linked list of integers. Implement this interface:


interface IntList {
  void prepend(int i);
  void append(int i);
  void deleteNth(int n);
  void insertAtNth(int n, int i);
  void deleteAllOdd();
  void deleteEveryOther();  // delete every other element, starting with the second
}

Implement all methods recursively.