Queue data structure

In the Queue data structure, we will cover following-

  • What is queue?
  • Types of queue
  • Main operations of queue
  • Applications of queue
  • Time complexity

What is queue?
A queue is a linear data structure just like a stack. But unlike a stack, a queue is open from both the ends. But it's both ends are not use for both the operation insertion(enqueue) and deletion(dequeue) rather from one end insertion takes place and from the other hand deletion takes place.
The end from where insertion takes place is called rear and the end from where deletion takes place is called front.
Moreover since a queue uses both the opposite ends for insertion and deletion. In other words, we say that it is based on the principle of First in first out(FIFO).
Example:-
Note:- If queue is an empty than rear points at -1 index position and front points at 0 index position.

Types of queue:-
There are mainly 3 types of queue-
    1. Linear queue
    2. Circular queue
    3. Priority queue

Main operations of queue:-
Mainly the following two basic operations are performed on the queue data structure:-
1. void enqueue (int data):- inserts data/item at the end of a queue
2. int dequeue( ):- deletes and returns an item at the front of the queue


Applications of queue:-
There are following some important applications of queue data structure:-
1) Operating systems schedule jobs (with equal priority) in the order of arrival (e.g., a print queue)
2) Example of real-world queues such as lines at a ticket counter, banks, or any other first come first-served scenario requires a queue.
3) Multi-programming
4) Waiting times of costumers in call centers

5) Asynchronous data transfer like- file IO, pipes, sockets etc

Time complexities of operations performed on queue:- Just like a Stack, in case of a Queue too,Time complexity will be O(1) because we do not run any loop in any of these operations.

also see:-
Data structure and it's classification
Stack data structure
Searching algorithm in data structure

Post a Comment

0 Comments