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;
}
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+
$10 USD/m
Billed $120 USD annually
Homework Help
Class Notes
Textbook Notes
40 Verified Answers
Study Guides
Booster Classes
Class+
$8 USD/m
Billed $96 USD annually
Homework Help
Class Notes
Textbook Notes
30 Verified Answers
Study Guides
Booster Classes