QUEUE ADT IN DATA STRUCTURES
BY,
SUBHALAKSHMI.S
M.Sc(Computer Science)
Nadar saraswathi college of arts and science.
CONTENTS:
Queue ADT
Queue ADT Operations
Circular Queue
Linked List Based Implementation
Applications of Queues
Queue Abstract Data Type(ADT):
 It Insert at one end of List and remove at the other end.
 Queues are “FIFO” (first in first out).
Operations:
 The Primary operations are Enqueue and Dequeue.
 Enqueue - add an entry at the end of the queue (also called “rear” or “tail”).
 Dequeue - remove the entry from the front of the queue.
CIRCULAR QUEUE:
 Circular Queue is a linear data structure in which the operations are performed
based on FIFO(First In First Out).
 The last position is connected back to the first position to make a circle.
 It is also called ’Ring Buffer’.
 This function is used to insert an element into the circular queue.
Basic Features:
1.Incase of a circular queue, head pointer will always point to
front of the queue and tail pointer will always point to the end of the queue.
2.Initially, the head and tail pointers will be pointing to the
location, this would mean that the queue is empty.
3.New data is always added to the location pointed by the tail pointer, and
once the data is added tail pointer is incremented to point to the next available location.
4.In a circular queue, data is not actually removed from the queue. Only the
head pointer is incremented by one position when dequeue, is executed. As the queue
data is only the data between head and tail, hence the data left outside is not a part of
the queue anymore, hence removed.
5.The head and the tail pointer will get reinitialized to 0 every time they reach the end
of the queue.
6.Also, the head and tail pointers can across each other. In other words, head pointer
can be greater than the tail.
Linked List Based Implementation:
Pointer‐Based Implementation
 Can be implemented using linear linked list or circular linked list.
 Linear linked list
Need two external pointer (front and back)
• Circular linked list
Need only one pointer, that point at back.
Need 2 structure
 Declaration of the node
struct nodeQ {
char item;
nodeQ * next;
}
 Declaration of the queue
class queue
{public:
nodeQ *backPtr, * frontPtr;
// operations for queue
};
APPLICATIONS OF QUEUES:
 Printer Queue: Jobs submitted to a printer are printed in order of
arrival.
 Phone calls made to customer service hotlines are usually placed in a
queue.
 File servers: Users needing access to
their files on a shared file server machine are given access on a FIFO Basis.
Ds

Ds

  • 1.
    QUEUE ADT INDATA STRUCTURES BY, SUBHALAKSHMI.S M.Sc(Computer Science) Nadar saraswathi college of arts and science.
  • 2.
    CONTENTS: Queue ADT Queue ADTOperations Circular Queue Linked List Based Implementation Applications of Queues
  • 3.
    Queue Abstract DataType(ADT):  It Insert at one end of List and remove at the other end.  Queues are “FIFO” (first in first out).
  • 4.
    Operations:  The Primaryoperations are Enqueue and Dequeue.  Enqueue - add an entry at the end of the queue (also called “rear” or “tail”).  Dequeue - remove the entry from the front of the queue.
  • 5.
    CIRCULAR QUEUE:  CircularQueue is a linear data structure in which the operations are performed based on FIFO(First In First Out).  The last position is connected back to the first position to make a circle.  It is also called ’Ring Buffer’.  This function is used to insert an element into the circular queue.
  • 7.
    Basic Features: 1.Incase ofa circular queue, head pointer will always point to front of the queue and tail pointer will always point to the end of the queue. 2.Initially, the head and tail pointers will be pointing to the location, this would mean that the queue is empty.
  • 8.
    3.New data isalways added to the location pointed by the tail pointer, and once the data is added tail pointer is incremented to point to the next available location. 4.In a circular queue, data is not actually removed from the queue. Only the head pointer is incremented by one position when dequeue, is executed. As the queue data is only the data between head and tail, hence the data left outside is not a part of the queue anymore, hence removed.
  • 9.
    5.The head andthe tail pointer will get reinitialized to 0 every time they reach the end of the queue.
  • 10.
    6.Also, the headand tail pointers can across each other. In other words, head pointer can be greater than the tail. Linked List Based Implementation: Pointer‐Based Implementation  Can be implemented using linear linked list or circular linked list.  Linear linked list Need two external pointer (front and back)
  • 11.
    • Circular linkedlist Need only one pointer, that point at back. Need 2 structure  Declaration of the node struct nodeQ { char item; nodeQ * next; }
  • 12.
     Declaration ofthe queue class queue {public: nodeQ *backPtr, * frontPtr; // operations for queue };
  • 13.
    APPLICATIONS OF QUEUES: Printer Queue: Jobs submitted to a printer are printed in order of arrival.  Phone calls made to customer service hotlines are usually placed in a queue.  File servers: Users needing access to their files on a shared file server machine are given access on a FIFO Basis.