Saturday, March 9, 2019

QUEUE USING LINKED LIST REPRESENTATION


  • The queue using array in very easy and convenient,but it allows only to represent a fixed sized queues.
  • In general applications, the size of the queue may be vary during the program execution,in such a situation the linked list representation of queue  is very useful.
Insert the element at queue using linked list:


  • Initially front=rear=null.
  • Insert 10 in queue using linked list representation
                           
  • After the second insertion
                                          
  • After the third insertion
                                
Initially the list is empty,so both the front and rear pointers are Null.the insert function creates a new node, puts the new data value in it, appends it to an existing list,and makes the rear pointer points  to it.

Delete the element from queue using linked list:
  • Initially the elements in Queue
                                      
  • After deleting the element 30
                            
A delete function checks whether the queue is empty and if not,retrieves the data value of the node pointed to by the front, advance the front & remove the storage of the node whose data value has been retrieved.
                      ********







No comments:

Post a Comment