0% found this document useful (0 votes)
3 views

Queue

The document provides an overview of queues, a linear data structure used for temporary data storage, highlighting types such as Simple Queue, Circular Queue, Priority Queue, and Dequeue. It explains the operations associated with queues including Enqueue and Dequeue, as well as their applications in areas like CPU scheduling and real-life scenarios like call centers. The document emphasizes the First-in-First-out property of queues and the differences in efficiency and memory usage among the various types of queues.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Queue

The document provides an overview of queues, a linear data structure used for temporary data storage, highlighting types such as Simple Queue, Circular Queue, Priority Queue, and Dequeue. It explains the operations associated with queues including Enqueue and Dequeue, as well as their applications in areas like CPU scheduling and real-life scenarios like call centers. The document emphasizes the First-in-First-out property of queues and the differences in efficiency and memory usage among the various types of queues.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Queue

• the linear data structure type which is used to organize the data
• It is used for temporary storage of data values
• A new element is added at one end called rear end
Queue • The existing element deleted from the other end is called front end
• First-in-First-out property
CS1332 Programming Language

Type of Queue Simple Queue


1. Simple Queue • Defines the simple operation of queue in which insertion occurs at the
2. Circular Queue rear of the list and deletion occurs at the front of the list
3. Priority Queue
4. Dequeue (double ended queue)
Circular Queue Priority Queue
• All nodes are treated as circular. • Contains data items which have some
Last node is connected back o the preset priority. While removing an
first node. element from a priority queue, the data
• Also called as Ring Buffer item with the highest priority is removed
first
• It is an abstract data type
• In a priority queue, insertion is performed
• Contains a collection of data which in the order of arrival and deletion is
allows insertion of data at the performed based on the priority
beginning of the queue

Dequeue (double ended queue) Linear Queue Circular Queue


• In a double ended queue, insert and delete operation can be occur at • A linear data structure that stores • A linear data structure in which
both ends that is front and rear of the queue data as a sequence of element the last item connects back to the
similar to a real world queue first item forming a circle.
• Possible to enter new items from • Possible to enter and remove
the rear end and remove the elements from any position
items from the front • Requires less memory
• Requires more memory • More efficient
• Less efficient
Operations on Queue Enqueue Operation
• Enqueue() – add (store) an item to the queue 1. Check if the queue is full
• Dequeue – remove (access) an item from the queue 2. If the queue is full, produce overflow
• Peek() – gets the element at the front of the queue without removing it error and exit
• isfull() – checks if the queue is full 3. If the queue is not full, increment rear
pointer to point the next empty space
• Isempty() – checks if the queue is empty
4. Add data element to the queue
location where the rear is pointing
5. Return success

Dequeue Operation Application of Queue


1. Check if the queue is empty • Useful in CPU scheduling, disk scheduling
2. If the queue is empty, produce • When data is transferred asynchronously between two process. Queue
underflow error and exit is used for synchronization. Examples: IO Buffers, pipes, file IO, etc
3. If the queue is not empty, access • In real life, call center phone systems will use queues, to hold people
the data where front is pointing calling them in an order, until a service representative is free.
4. Increment front pointer to point
to the next available data element
5. Return success
Thank You!

You might also like