Queue and Implementation

Queue :

  • Queue is an abstract data type.
  • It is an ordered collection of elements.
  • It works on FIFO( First In First Out )principle
  • Insertion is done at REAR end and Deletion is done at a FRONT end.
  • It can be implemented using both array or linked list.
  • A FRONT pointer is used to point the front end of the list or array and REAR pointer is used for pointing REAR end of the list or array.

OVERFLOW : Overflow occurs when the queue is full to it’s maximum size and further insertion can’t be done. Conditions are:  REAR=Max

UNDERFLOW : Underflow occurs when Queue is having zero elements and a deletion is performed on it. Conditions for underflow are: REAR=FRONT=-1

Algorithms for Insertion and Deletion in Queue:

For array implementation

INSERTION

Insertion in Queue

DELETION

Deletion in Queue

C SOURCE CODE (Queue using array)


For Linked list implementation

Queue using Linked List

INSERTION

Insertion in Queue - Step 1

(1)

Insertion in Queue - Step 2

 (2)

Insertion in Queue - Step 3

(3)

DELETION

Deletion in Queue - Step 1

(1)

Deletion in Queue - Step 2

(2)

Deletion in Queue - Step 3

(3)

C SOURCE CODE(Queue using Linked List)

Leave a Reply

Your email address will not be published. Required fields are marked *