Class Notes (1,100,000)
CA (630,000)
UW (20,000)
CS (1,000)
CS138 (10)
Lecture 8

CS138 Lecture Notes - Lecture 8: Information Hiding


Department
Computer Science
Course Code
CS138
Professor
Michael Godfrey
Lecture
8

This preview shows half of the first page. to view the full 2 pages of the document.
Data Lecture 8
January 31, 2013
Node Examples
Node Header
#include <iostream>
#include <string>
#include <cassert>
using namespace std;
struct Node {
string val;
Node* next;
};
typedef vector<string> Stack;
bool isMT (Node* Stack s) {
return (NULL==s);
}
Node* push (Node* Stack s, string val) {
Node * newNode = new Node;
newNode -> val=val;
newNode -> next=s;
return newNode;
}
string peek (Node* Stack s) {
assert (!isMT(s));
return s-> val;
}
Node* initStack() {
return NULL;
}
Node* pop (Node* Stack s) {
assert (!isMT(s));
Node *p = s -> next;
delete s;
return p;
}
Node* nuke (Node* Stack s) {
while (NULL!=s) {
Node *p = s -> next;
delte s;
s=p;
}
return NULL;
}
You're Reading a Preview

Unlock to view full version