Queue

Queue introduction
                 Queue is a linear Data structure which allows operations in a particular order i.e. rear or front end only. The order of queue is First In First Out (FIFO) or First Come First serve (FCFS).
                 A good example of queue is any queue of consumers for a resource where the consumer that came first is served first.
                  The difference between stacks and queues is in removing. In a stack we remove the item the most recently added; in a queue, we remove the item the least recently added.

Operations on Queue:- Mainly the following three basic operations are performed on queue:
      1. Qinsert
      2. Qdelete
      3. Qdisplay
Qinsert (Enqueue):- Adds an item to the queue. If the queue is full, then it is said to be an Overflow condition.
Qdelete (Dequeue):- Removes an item from the queue. The items are popped in the same order in which they are pushed. If the queue is empty, then it is said to be an Underflow condition.
Qdisplay :- Displaying all elements without deletion 
Types of Queue:- Queue can be of four types:
  1. Linear/Simple Queue
  2. Priority Queue
  3. Circular Queue
  4. Dequeue (Double Ended queue)
Linear/Simple Queue:- In linear queue all items are arranged in linear fashion. 

Priority Queue:-In this queue all elements are process according to key value called priority, Witch element having high priority that one will process first. 

Circular Queue:- As in a circle after last element, first element occurs.

Double Ended queue:- Dequeue is also called double ended queue, as the name implies we can add or delete the element from both sides. Dequeue can be of two types
    1. Input restricted:- in input restricted dequeue, elements can be added from only one end but we can delete the element from both sides.
    2. Output restricted:- in output restricted dequeue element can be added from both ends but deletion is allowed only at one end.

0 comments:

Post a Comment