1
Index
S.No Topic Slide No.
1. Introduction 3
2. Representation Of Queue 5
3. Three States Of Queue 6
4. Applications Of Queue 7
5. Types Of Queue 8
6. Circular Queue 9
7. Double – Ended Queue (Deque) 10
8. Operations On Deque 11
9. Application Of Queue 12
10. Priority Queue 13
11. Application Of Priority Queue 14
2
Introduction
Queue is an ADT data structure similar to stack, except
that the first item to be inserted is the first one to be
removed.
This mechanism is called First-In-First-Out (FIFO).
Placing an item in a queue is called “insertion or
enqueue”, which is done at the end of the queue called
“rear”.
Removing an item from a queue is called “deletion or
dequeue”, which is done at the other end of the queue
called “front”.
Some of the applications are : printer queue, keystroke
queue, etc.
3
C
B C
A B C
A
b a c k
f r o n t
p u s h A
A B
f r o n t b a c k
p u s h B
f r o n t b a c k
p u s h C
f r o n t b a c k
p o p A
f r o n t
b a c k
p o p B
A Queue is a FIFO (First in First
Out) Data Structure. Elements
are inserted in the Rear of the
queue and are removed at the
Front.
4
Representation Of Queue
Using An Array
Using A Linked List
5
3 States Of Queue
Queue is Empty :
 Front = Rear
Queue is Full :
 Rear = N
Queue contains element >=1 :
 Front < Rear
 No. Of Element = Rear – Front + 1
6
Applications Of Queue
Real Life Applications
 Waiting in line
 Waiting on hold for tech support
Applications Related to computer life
 Round Robin Scheduling
 Job Scheduling
 Key Board Buffer
7
Types Of Queue
Circular Queue
Double Ended Queue (Deque)
Priority Queue
8
Circular Queue
When a new item is inserted at the rear, the pointer to
rear moves upwards.
Similarly, when an item is deleted from the queue the
front arrow moves downwards.
After a few insert and delete operations the rear might
reach the end of the queue and no more items can be
inserted although the items from the front of the queue
have been deleted and there is space in the queue.
To solve this problem, queues implement wrapping
around. Such queues are called Circular Queues.
Both the front and the rear pointers wrap around to the
beginning of the array
9
Double – Ended Queue (Deque)
Items can be inserted and deleted from either ends.
Input Restricted Deque: Elements can be inserted at
only at one end but can be removed from both ends.
Output Restricted Deque: Elements can be inserted at
both ends and can be removed only from one side
10
Operations On Deque
Insert element at back
Insert element at front
Remove element at front
Remove element at back
11
Applications Of Deque
A-Steal job scheduling algorithm
The A-Steal algorithm implements task scheduling for
several processors(multiprocessor scheduling).
The processor gets the first element from the deque.
When one of the processor completes execution of its own
threads it can steal a thread from another processor.
 It gets the last element from the deque of another
processor and executes it.
Undo-Redo : operations in Software applications.
12
Priority Queue
A Special form of queue from which items are removed
according to their designated priority and not the order in
which they entered.
Items are removed from the front.
Items are ordered by key value so that the item with the
lowest key (or highest) is always at the front.
Items are inserted in proper position to maintain the
order.
13
Applications Of Priority Queue
Standby flyers
Auctions
Stock market
Sorting
Huffman Coding
14

Queue Data Structure

  • 1.
  • 2.
    Index S.No Topic SlideNo. 1. Introduction 3 2. Representation Of Queue 5 3. Three States Of Queue 6 4. Applications Of Queue 7 5. Types Of Queue 8 6. Circular Queue 9 7. Double – Ended Queue (Deque) 10 8. Operations On Deque 11 9. Application Of Queue 12 10. Priority Queue 13 11. Application Of Priority Queue 14 2
  • 3.
    Introduction Queue is anADT data structure similar to stack, except that the first item to be inserted is the first one to be removed. This mechanism is called First-In-First-Out (FIFO). Placing an item in a queue is called “insertion or enqueue”, which is done at the end of the queue called “rear”. Removing an item from a queue is called “deletion or dequeue”, which is done at the other end of the queue called “front”. Some of the applications are : printer queue, keystroke queue, etc. 3
  • 4.
    C B C A BC A b a c k f r o n t p u s h A A B f r o n t b a c k p u s h B f r o n t b a c k p u s h C f r o n t b a c k p o p A f r o n t b a c k p o p B A Queue is a FIFO (First in First Out) Data Structure. Elements are inserted in the Rear of the queue and are removed at the Front. 4
  • 5.
    Representation Of Queue UsingAn Array Using A Linked List 5
  • 6.
    3 States OfQueue Queue is Empty :  Front = Rear Queue is Full :  Rear = N Queue contains element >=1 :  Front < Rear  No. Of Element = Rear – Front + 1 6
  • 7.
    Applications Of Queue RealLife Applications  Waiting in line  Waiting on hold for tech support Applications Related to computer life  Round Robin Scheduling  Job Scheduling  Key Board Buffer 7
  • 8.
    Types Of Queue CircularQueue Double Ended Queue (Deque) Priority Queue 8
  • 9.
    Circular Queue When anew item is inserted at the rear, the pointer to rear moves upwards. Similarly, when an item is deleted from the queue the front arrow moves downwards. After a few insert and delete operations the rear might reach the end of the queue and no more items can be inserted although the items from the front of the queue have been deleted and there is space in the queue. To solve this problem, queues implement wrapping around. Such queues are called Circular Queues. Both the front and the rear pointers wrap around to the beginning of the array 9
  • 10.
    Double – EndedQueue (Deque) Items can be inserted and deleted from either ends. Input Restricted Deque: Elements can be inserted at only at one end but can be removed from both ends. Output Restricted Deque: Elements can be inserted at both ends and can be removed only from one side 10
  • 11.
    Operations On Deque Insertelement at back Insert element at front Remove element at front Remove element at back 11
  • 12.
    Applications Of Deque A-Stealjob scheduling algorithm The A-Steal algorithm implements task scheduling for several processors(multiprocessor scheduling). The processor gets the first element from the deque. When one of the processor completes execution of its own threads it can steal a thread from another processor.  It gets the last element from the deque of another processor and executes it. Undo-Redo : operations in Software applications. 12
  • 13.
    Priority Queue A Specialform of queue from which items are removed according to their designated priority and not the order in which they entered. Items are removed from the front. Items are ordered by key value so that the item with the lowest key (or highest) is always at the front. Items are inserted in proper position to maintain the order. 13
  • 14.
    Applications Of PriorityQueue Standby flyers Auctions Stock market Sorting Huffman Coding 14