QUEUE USING LINKED LIST
ALGORITHM FOR PUSHING AN ELEMENT TO A QUEUE
1. Input the VALUE element to be pushed
2. Create a New Node
3. NewNode -> DATA = VALUE
4. NewNode -> Next = NULL
// if it is not empty
5. If(REAR not equal to NULL)
(a) REAR -> next = NewNode
(b) REAR = NewNode
6. Else
REAR = FRONT = NewNode
7. Exit
36
QUEUE USING LINKED LIST
ALGORITHM FOR POPPING ELEMENT FROM A QUEUE
1. If (FRONT is equal to NULL)
Display "The Queue is
empty"
2. Else
(a) print FRONT -> DATA
(b) TEMP = FRONT
(c) FRONT = FRONT -> Next
(d) If(FRONT is equal to NULL)
REAR = NULL
(e) Free the TEMP node
3. Exit
37
DOUBLY LINKED LIST
Every nodes in the doubly linked list has three fields:
LeftPointer, RightPointer and DATA.
38
REPRESENTATION OF DOUBLY LINKED LIST
•A node in the doubly linked list can be represented
with the following declarations:
struct Node
{
int DATA;
Node * next;
Node * prev;
};
Node *
START;
•All operations performed on singly linked list can also
be performed on doubly linked list. 39

ALGORITHM FOR PUSHING AN ELEMENT TO A QUEUE

  • 1.
    QUEUE USING LINKEDLIST ALGORITHM FOR PUSHING AN ELEMENT TO A QUEUE 1. Input the VALUE element to be pushed 2. Create a New Node 3. NewNode -> DATA = VALUE 4. NewNode -> Next = NULL // if it is not empty 5. If(REAR not equal to NULL) (a) REAR -> next = NewNode (b) REAR = NewNode 6. Else REAR = FRONT = NewNode 7. Exit 36
  • 2.
    QUEUE USING LINKEDLIST ALGORITHM FOR POPPING ELEMENT FROM A QUEUE 1. If (FRONT is equal to NULL) Display "The Queue is empty" 2. Else (a) print FRONT -> DATA (b) TEMP = FRONT (c) FRONT = FRONT -> Next (d) If(FRONT is equal to NULL) REAR = NULL (e) Free the TEMP node 3. Exit 37
  • 3.
    DOUBLY LINKED LIST Everynodes in the doubly linked list has three fields: LeftPointer, RightPointer and DATA. 38
  • 4.
    REPRESENTATION OF DOUBLYLINKED LIST •A node in the doubly linked list can be represented with the following declarations: struct Node { int DATA; Node * next; Node * prev; }; Node * START; •All operations performed on singly linked list can also be performed on doubly linked list. 39