Lecture13-3 - DataStructures CSCI 132, Spring 2012 Lecture...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Data Structures   CSCI 132, Spring 2012 Lecture 13 Queues as Linked Lists, Polynomial Arithmetic
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Queues as Linked Lists entry 1 entry 2 entry 3 front class Queue { public: Queue(); bool empty() const; Error_code append (const Queue_entry &item); Error_code serve( ); Error_code retrieve(Queue_entry &item) const; ~Queue(); Queue(const Queue &original); void operator =(const Queue &original); protected: Node *front, *rear; }; rear
Background image of page 2
3 append( ) implementation }
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 append( ) implementation Node *new_rear = new Node(item); if (new_rear == NULL) { return overflow; } if (rear == NULL) { front = rear = new_rear; } else { rear->next = new_rear; rear = new_rear; } return success; }
Background image of page 4
5 Implementing serve( ) Error_code Queue :: serve( ) { }
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Implementing serve( ) Error_code Queue :: serve( ) { if (front == NULL) { return underflow; } Node *old_front = front; front = old_front->next; if (front == NULL) { rear = NULL; } delete old_front; return success; }
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 11

Lecture13-3 - DataStructures CSCI 132, Spring 2012 Lecture...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online