CEG's Linux User Group

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

CIRCULAR QUEUE IMPLEMENTATION USING LINKED LIST - DOCUMENTATION

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

 

GOAL OF THE CODE:

 

To implement a circular queue using LINKED LIST.

 

VARIABLES USED:


1.a- structure variable which contains the value of the node.
2.node,next-pointers to the structure qnode.
3.new- pointer variable which points to the newly inserted node.
4.temp-variable which temporarily stores a value.
5.end-pointer variable which points to the last node.
6.x- local variable which contains the element to be inserted in the list.
7.n-variable in main() which stores the choice entered by the user.

FUNCTIONS USED:

 

FUNCTION

PURPOSE

createqueue()

Dynamically allocates memory for the queue.

displayq()

Displays the contents of the queue.

isempty()

Returns 1 if the queue is empty else returns 0.

insert()

Inserts elements into the queue.

delete()

Deletes elements from the queue.

front()

Returns the front most element of the queue.

frontdel()

Deletes the front most element and then returns the value pointed out by the front pointer.

     

     

    IMPLEMENTAION:

  1. Initially,the maximum no.of elements to be stored in the queue is obtained from the user.

  2. A circular queue is created by dynamically allocating memory using createqueue() function.

  3. Then, choices are provided to the user from which one can choose the operation to be performed.

  4. A switch case is made use of in this code. Depending upon the choice entered by the user,the corresponding operations are performed.

  5. After each operation,the display() function is called so that the user can better understand the implementation.

  6. If the user enters a number that has not been specified in the cases, the default case is executed and the program terminates.

Initialization: Assign the address of the header node to the address part of the next node(also known as emptying the queue).



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