[prev] [index] [next]

Exercise: Stack Data Type

Implement a Stack (of ints) data type using linked lists:

typedef struct stackNode { ... } StackNode;
typedef struct stackRep { ... } StackRep;
typedef StackRep *Stack;

Stack emptyStack();   // make an empty Stack
int height(Stack s);  // # values in Stack
int isEmpty(Stack s); // is Stack empty?
push(Stack s, int v); // add value on top 
int pop(Stack s);     // remove top value