CEG's Linux User Group

  • Increase font size
  • Default font size
  • Decrease font size
Home Labs CIRCULAR QUEUE IMPLEMENTATION USING LINKED LIST

CIRCULAR QUEUE IMPLEMENTATION USING LINKED LIST

E-mail Print
User Rating: / 6
PoorBest 
Article Index
CIRCULAR QUEUE IMPLEMENTATION USING LINKED LIST
SOURCE CODE
DOCUMENTATION
TEST CASE AND COMPATIBILITY
All Pages

IMPLEMENTATION OF A CIRCULAR QUEUE USING

LINKED LIST

 

INTRODUCTION:

We know that a linear queue is a “first in first out “ data structure,i.e., insertion can be made only at the end and deletion can be made only at the front. In a linear queue, the traversal through the queue is possible only once,i.e.,once an element is deleted,we cannot insert another element in its position.

This disadvantage of a linear queue is overcome by a circular queue, thus saving memory. In a circular queue, after rear reaches the end of the queue, it can be reset to zero. This helps in refilling the empty spaces in between.

A linked list is a data structure that consists of a sequence of nodes. Each node consists of two fields-information and address. The information part contains the value that the node holds. The address part contains the address of the next node. The last node contains NULL in the address part.

NODE 1                                        NODE 2                                         NODE 3

img4

INFO              ADDRESS                           2000                                              2002

 

In a linked list, the nodes are logically connected but they may not be physically adjacent. This makes lists more advantageous than arrays where the data must be physically adjacent and at the same time logically connected. Here, nodes can be inserted and deleted at any point in the list unlike stacks, queues. But it is possible to implement a circular queue using a linked list.



Last Updated on Saturday, 13 June 2009 08:21  
Please register or login to add your comments to this article.