DS – Queue using Linked List

Queue using Single Linked List

Insert element into Queue:

  • Initially front and rear values are NULLs
  • Insertion must be done through rear variable.
  • If no elements in the list, front = rear = new ;
  • If list has elements, we need to add the node at the end (link to rear)

Deleting element:

  • Deletion from front.
  • We must use front pointer to remove the element.
  • If front is null – return with message “List is empty”
  • If elements are present, remove the first node and make the front pointing to second node.

Note:

  • If you are deleting the last node using front, we need to make rear pointer assign to NULL.
  • We confirm last node by checking the condition front == rear

Display Queue elements:

  • Check the Queue is empty or not
  • If empty , return with error message
  • If not, display all elements in the Queue.

Scroll to Top