Thursday, 25 June 2015

Queues in Data Structures

A queue  is linear data structure where the elements are stored in linear manner. A queue  is also called as FIFO ( Fist In First Out) that is the first inserted element is deleted first. The following are some of the real time situations where you can see queue applications.

  • In operating systems where the jobs are waiting for resources are minted in a queue  called waited queue .
  • In Transport where all the vehicle follow the queue 
  • In computer science engineering applications.

queue  of people waiting for some thing
           In Data structure a queue is also use similarly as above image and elements are inserted at one end called rear end  and are deleted at another end called front end. The following figure shows this



                              In the above Figure the element 6 is entered first and it is deleted first, that is why java called as FIFO. The insertion operation is called Enqueue  and the deletion operation is called Dequeue. All the general operations performed on a data structure can be done on queue.

Basic Queue Operations

As we have know, queue is nothing but the collection of items. Both the ends of the queue are having their own functionality. The queue is also called as FIFO. All the elements in the queue are stored sequentially. The various operations on the queue are-

  1. Queue overflow 
  2. Insertion of elements into the queue
  3. Queue underflow
  4. Deletion of the elements from the queue
  5. Displaying of the queue
C representation of Queue is

struct queue
{
    int que[size];
   int front;
  int rear;
}

Insertion of element int the queue


                                                    The insertion of any element in the queue will always take place from the rear end. Before performing insertion operation you must check whether the queue is full or not. If the rear pointer is going beyond the maximum size of the queue then the queue overflow occurs
.

Deletion of element from the queue

                        
                                                        The deletion of any element in the queue takes place by the front end always.Before performing any delete operation one must check whether the queue is empty or not. If the queue is empty, you can't perform the deletion. The result is illegal attempt to delete an element from the empty queue is called the queue Underflow condition.

Applications of Queue

 The following are the applications of Queue


  • Queue are used in operating systems for scheduling the jobs
  • Queue are for categorizing data
  • Queue are used in simulation and modeling
 

0 comments :

Post a Comment

Note: only a member of this blog may post a comment.

Machine Learning

More

Advertisement

Java Tutorial

More

UGC NET CS TUTORIAL

MFCS
COA
PL-CG
DBMS
OPERATING SYSTEM
SOFTWARE ENG
DSA
TOC-CD
ARTIFICIAL INT

C Programming

More

Python Tutorial

More

Data Structures

More

computer Organization

More
Top