A queue is an abstract data structure that operates on a First-In-First-Out (FIFO) basis, allowing insertion at one end (rear) and deletion at the other end (front). It can be represented in memory using arrays or linked lists, with specific operations for insertion and deletion that can lead to overflow or underflow conditions. Queues have various applications in computer science, including job scheduling, printer buffering, and managing user requests in service applications.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
4 views19 pages
Queue
A queue is an abstract data structure that operates on a First-In-First-Out (FIFO) basis, allowing insertion at one end (rear) and deletion at the other end (front). It can be represented in memory using arrays or linked lists, with specific operations for insertion and deletion that can lead to overflow or underflow conditions. Queues have various applications in computer science, including job scheduling, printer buffering, and managing user requests in service applications.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19
Introduction of Queue
Operations on the Queue
Memory Representation of Queue Array representation of queue Linked List Representation of Queue Circular Queue Some special kinds of queues Dequeue, Priority Queue Application of Priority Queue Applications of Queues. Queue: Queue is an abstract data structure, somewhat similar to Stacks. Unlike stacks, a queue is open at both its ends. One end is always used to insert data (enqueue) and the other is used to remove data (dequeue). Queue follows First-In-First-Out methodology, i.e., the data item stored first will be accessed first. Defination of Queue: Queue is a linear collection of elements in which insertion takes place at one end known as rear and deletion takes place at another end known as front of the queue. The elements of a queue are processed in the same order as they were added into the queue.That’s why queues are also known as FIFO(First In First Out)list.The elements of a general queue are processed on first come first serve basis(FCFS). Areal-world example of queue can be a single-lane one-way road, where the vehicle enters first, exits first. More real-world examples can be seen as queues at the ticket windows and bus-stops. Queue Representation Operations on the Queue:
Two basic operations which are
performed on queue are: Insertion Deletion The insertion operation refers to addition of a new element at the rear of the queue Insertion operation can be performed only when queue has space to accommadate the new element.The condition of attempting to insert an element in a queue having no space results in a state called overflow condition. Deletion operation refers to the removal of an element from the front of the queue.Deletion operation can be performed only when the queue is not empty.The condition of attempting to delete an element from the empty queue is known as underflow condition. Memory Representation of Queue: Like Stacks, Queues can also be represented in memory in two ways. Using the contiguous memory like an array Using the non-contiguous memory like a linked list Using the Contiguous Memory like an Array In this representation the Queue is implemented using the array. Variables used in this case are QUEUE- the name of the array storing queue elements. FRONT- the index where the first element is stored in the array representing the queue. REAR- the index where the last element is stored in array representing the queue. MAX- defining that how many elements (maximum count) can be stored in the array representing the queue. Using the Non-Contiguous Memory like a Linked List In this representation the queue is implemented using the dynamic data structure Linked List. Using linked list for creating a queue makes it flexible in terms of size and storage. You don’t have to define the maximum number of elements in the queue. Pointers (links) to store addresses of nodes for defining a queue are. FRONT- address of the first element of the Linked list storing the Queue. REAR- address of the last element of the Linked list storing the Queue. Queue Applications
Queues are used in various applications in
Computer Science- Job scheduling tasks of CPU. Printer’s Buffer to store printing commands initiated by a user. Input commands sent to CPU by devices like Keyboard and Mouse. Document downloading from internet. User Requests for call center services. Order Queue for Online Food Delivery Chains. Online Cab Booking applications.