CS1500 Algorithms and Data Structures for Engineering, FALL 2012

 LAB 10: Stacks and Queues

A. Implement a class for Stacks using an array for storage.
class Stack{
private:
    int *data;
    int size;
    int top;
public:
    Stack();
    ~Stack();
    void push(int);
    int pop();
}
Main: Declare a stack; run a sequence  of  push() and pop() operations to demonstrate your code.

B. Implement a class for Queues, using an array for storage.
class Queue{
private:
    int *data;
    int size;
    int builder;
    int consumer;
public:
    Queue();
    ~Queue();
    void enqueue(int);
    int dequeue();
}
  Declare a queue; run a sequence of enqueue(), dequeue() operations to demonstrate your code.


EXTRA CREDIT. Re-implement stacks using linked lists rather than arrays.