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

Data Lecture 10.docx


Department
Computer Science
Course Code
CS138
Professor
Michael Godfrey
Lecture
10

This preview shows half of the first page. to view the full 2 pages of the document.
Data Lecture 10
February 7, 2013
More Queues
<mumble> Queue
struct Node {
string val;
Node *next;
}
struct Queue {
vector <string> store;
int first;
}
Queue intQ() {
cerr<<"New queue\n";
Queue q;
q.first=NULL;
q.last=NULL;
return q;
}
bool isMTQ (Queue q) {
cerr<<"isMTQ\n";
return NULL==q.last;
}
Queue enter (Queue q, string val) {
cerr<<"enter "<<val<<endl;
Node *newNode;
newNode = new Node;
newNode->val = val;
newNode->next = null;
if (NULL==q.first) {
cerr<<"One element"<<endl;
q.first = newNode;
}
else {
cerr<<">1 elements">>endl;
q.last->next = newNode;
}
q.last = newNode;
return q;
}
You're Reading a Preview

Unlock to view full version