










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!











(^) Queues: (^) Array and list representation, (^) Operations (traversal, insertion and deletion) (^) Priority queues and Deques: (^) Array and List representations
A Queue is an ordered collection of items from which items may be deleted at one end (called the front of the queue) and into which items may be inserted at the other end (the rear of the queue). The first element inserted into the queue is the first element to be removed. For this reason a queue is sometimes called a FIFO (first-in first- out) list as opposed to the stack, which is a LIFO (last-in first-out).
A new item ( A ) is inserted at the Rear of the queue items[MAXQUEUE -1]
.. .. items[3] items[2] items[1] items[0] A Front=0, Rear= 0
A new item ( B ) is inserted at the Rear of the queue items[MAXQUEUE -1]
.. .. items[3] items[2] items[1] B Rear= 1 items[0] A Front=
A new item ( D ) is inserted at the Rear of the queue items[MAXQUEUE- 1]
.. .. items[3] D Rear=^3 items[2] C items[1] B items[0] A Front=
QINSERT(QUEUE, N, FRONT, REAR, ITEM) 1.If FRONT = 1 and REAR = N, or FRONT = REAR + 1, then : write OVERFLOW, and Return.
An item ( B ) is deleted from the Front of the queue. items[MAXQUEUE-1]
.. .. items[3] D Rear= items[2] C Front= 2 items[1] B items[0] A
An item ( C ) is deleted from the Front of the queue items[MAXQUEUE-1]
.. .. items[3] D Front=Rear= 3 items[2] C items[1] B items[0] A
QDELETE(QUEUE, N, FRONT, REAR, ITEM) 1.If FRONT = NULL then : write: UNDERFLOW, and Return.
LINKQ_INSERT(INFO, LINK, FRONT, REAR, AVAIL, ITEM) 1.If AVAIL = NULL, then : write OVERFLOW, and Exit.
More specialized data structure. Similar to Queue, having front and rear. Items are removed from the front. Items are ordered by key value so that the item with the lowest key (or highest) is always at the front. Items are inserted in proper position to maintain the order.
It is a double-ended queue. Items can be inserted and deleted from either ends. More versatile data structure than stack or queue. E.g. policy-based application (e.g. low priority go to the end, high go to the front)