Introduction of queue

What is a Queue Data Structure?

Queue is also an abstract data type or a linear data structure, just like stack data structure, in which the first element is inserted from one end called the REAR(also called tail), and the removal of existing element takes place from the other end called as FRONT(also called head).
This makes queue as FIFO(First in First Out) data structure, which means that element inserted first will be removed first.
Which is exactly how queue system works in real world. If you go to a ticket counter to buy movie tickets, and are first in the queue, then you will be the first one to get the tickets. Right? Same is the case with Queue data structure. Data inserted first, will leave the queue first.
The process to add an element into queue is called Enqueue and the process of removal of an element from queue is called Dequeue.
Introduction to Queue

Basic features of Queue

  1. Like stack, queue is also an ordered list of elements of similar data types.
  2. Queue is a FIFO( First in First Out ) structure.
  3. Once a new element is inserted into the Queue, all the elements inserted before the new element in the queue must be removed, to remove the new element.
  4. peek( ) function is oftenly used to return the value of first element without dequeuing it.

Applications of Queue

Queue, as the name suggests is used whenever we need to manage any group of objects in an order in which the first one coming in, also gets out first while the others wait for their turn, like in the following scenarios:
  1. Serving requests on a single shared resource, like a printer, CPU task scheduling etc.
  2. In real life scenario, Call Center phone systems uses Queues to hold people calling them in an order, until a service representative is free.
  3. Handling of interrupts in real-time systems. The interrupts are handled in the same order as they arrive i.e First come first served.
Queue as an adt(abstract data type):-
The meaning of an abstract data type clearly says that for a data structure to be abstract, it should have the below-mentioned characteristics:
  • First, there should be a particular way in which components are related to each other
  • Second, a statement for the operation that can be performed on elements of abstract data type must have to be specified
Thus for defining a Queue as an abstract data type, these are the following criteria:
  • Initialize a queue to be empty
  • Check whether a queue is empty or not
  • Check whether a queue is full or not
  • Insert a new element after the last element in a queue, if the queue is not full
  • Retrieve the first element of the queue, if it is not empty
  • Delete the first element in a queue, if it is not empty.

                                                                                                       
Thank you viewers..
This is published by soumy sinha..
If you like this then pls subscribe and share with your friends..
Ask your next question with your feedback in comment section..

Comments

Popular posts from this blog

INTRODUCTION OF DBMS

Introduction of Digital computer

DEVELOPED, UNDEVELOPED AND DEVELOPING ECONOMIES || LIST, GDP, UNEMPLOYMENT