Resources » Articles/Knowledge Sharing » Computer & Technology

Queue, Queue operations and Queue application


Posted Date: 19-May-2011  Last Updated:   Category: Computer & Technology    
Author: Member Level: Gold    Points: 30


Queue concept is used in almost all the programming languages like C, C++, and JAVA. Queue uses the order FIFO (first-In-First-Out) by using the enqueue and dequeue operations. This article explains all about the queue, its various operations and the areas where the queue is used



Queue


Queue is the concept used in data structures. It is also referred to the linear data structure as the object or item can be added in one terminal and the item can be retrieved from the other end. Item, which is added to one end, is called as REAR and the item that is retrieved from the other end is called as FRONT. Queue is used in array as well as in linked list of the computer programs mainly used by the programmers. Queue follows the concept of FIFO (First-In-First-Out) . It means that the items, which are enters first will be accessed or retrieved first.

Best Example


The best example to represent the queue is the print jobs. Consider the systems are connected in the network with the common print using the print share methodology. So, whenever the users give their documents for printing, the jobs will be stored in a queue and the job which first enters the print queue will be printed first, which complies the concept of queue FIFO.

Queue Operations


The following are operations performed by queue in data structures
  • Enqueue (Add operation)
  • Dequeue (Remove operation)
  • Initialize

    Enqueue
    This operation is used to add an item to the queue at the rear end. So, the head of the queue will be now occupied with an item currently added in the queue. Head count will be incremented by one after addition of each item until the queue reaches the tail point. This operation will be performed at the rear end of the queue.

    Dequeue
    This operation is used to remove an item from the queue at the front end. Now the tail count will be decremented by one each time when an item is removed from the queue until the queue reaches the head point. This operation will be performed at the front end of the queue.

    Initialize
    This operation is used to initialize the queue by representing the head and tail positions in the memory allocation table (MAT).

    The other primitive operations of the queue are
  • Is empty – Checks whether the queue is empty. (If Is empty is true, then the addition of an item is possible. If this is false, then acknowledge with the message "Queue is empty")
  • Is full – Checks whether the queue is full. (If Is full is true, then the removal of an item is possible. If this is false, then acknowledge with the message "Queue is full")
  • Destroy – Deletes the contents of the queue.

    Let us now consider the following example of using the operation Enqueue and Dequeue.
    A queue of an array A[3] is initialized and now the size of the queue is 3 which represents the queue can hold a maximum of 3 items. The enqueue operation is used to add an item to the queue
    Enqueue (3) – This will add an item called 3 to the queue in the front end. (Front count will be incremented by 1)

    Again we are adding another item to the queue
    Enqueue (5) – This will add an item called 5 to the queue (Front count will be incremented by 1)

    Again we are adding the last item to the queue
    Enqueue (8) – This will add an item called 8 to the queue (Now the queue has reached its maximum count and hence no more addition of an item is possible in the queue, as the queue has reached the rear end)

    Now dequeue operation is performed to remove an item from the queue.
    Dequeue () – This will remove the item that has been added first in the queue, i.e., the item called 3 by following the concept of FIFO. Now the queue consists of the remaining items 5 and 8 in which the object 5 will be in the front end. The dequeue operation continues until the queue is reaching its last element.

    Queue Applications


    In the computer environment, the below areas where the queue concept will be implemented:
  • Print queue – Jobs sent to the printer
  • Operating system maintain queue in allocating the process to each unit by storing them in buffer
  • The interrupts that occurs during the system operation are also maintained in queue
  • The allocation of memory for a particular resources (Printer, Scanner, any hand held devices) are also maintained in queue.
  • Related Resources:


    Read related articles: Data Structure    

    Did you like this resource? Share it with your friends and show your love!




    Responses to "Queue, Queue operations and Queue application"

    No responses found. Be the first to respond...

    Feedbacks      

    Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index

    Awards & Gifts
    Active Members
    TodayLast 7 Daysmore...

    ISC Technologies, Kochi - India. Copyright © All Rights Reserved.