





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Class: DATA STRUCTURES; Subject: Computer Science; University: Oregon State University; Term: Fall 2006;
Typology: Study notes
1 / 9
This page cannot be seen from the preview
Don't miss anything!






Applications of Queues
Queue Implementation Techniques
Worksheet Q2: A Linked List Deque – using Double Links
struct dlink { EleType value; struct dlink * next;
struct dlink * prev; }; struct listDeque { struct dlink * frontSentinel; struct dlink * backSentinel; }; void ListDequeInit (struct listDeque *q) { q->frontSentinel = (struct dlink *) malloc(sizeof(struct dlink)); assert(q->frontSentinel != 0); q->backSentinel = (struct dlink *) malloc(sizeof(struct dlink)); assert(q->backSentinel); q->frontSentinel->next = q->backSentinel; q->backSentinel->prev = q->frontSentinal; } void ListDequeAddFront (struct listDeque *q, EleType e) { _addLink(q->frontSentinel, e); } void ListDequeAddback (struct listDeque *q, EleType e) { _addLink(q->backSentinel->prev, e); } void _addLink (struct dlink *lnk, EleType e) { } void listDequeRemoveFront (struct listDeque *q) { assert(! listDequeIsEmpty(q)); _removeLink (q->frontSentinal->next); } void ListDequeRemoveBack (struct listDeque *q) { assert(! listDequeIsEmpty(q)); _removeLink (q->backSentinel->prev); } void _removeLink (struct dlink *lnk) { } EleType ListDequeFront (struct listDeque *q) { } EleType ListDequeBack (struct listDeque *q) {
struct ArrayDeque { EleType * data; int count; int capacity; int start; }; void ArrayDequeInit (struct ArrayDeque *q) { q->start = q->count = 0; q->capacity = 5; q->data = (EleType *) malloc(q->capacity * sizeof(EleType)); assert(q->data); } void ArrayDequeAddFront (struct ArrayDeque *q, EleType e) { } void ArrayDequeAddBack (struct ArrayDeque *q, EleType e) { }
void ArrayDequeRemoveFront (struct ArrayDeque *q) { } void ArrayDequeRemoveBack (struct ArrayDeque *q) { } EleType ArrayDequeFront (struct ArrayDeque *q) { } EleType ArrayDequeBack (struct ArrayDeque *q) { } int ArrayDequeIsEmpty (struct ArrayDeque *q) { }
Self Study Questions
Short Exercises Analysis Exercises