Queues

A Queue is data structure in which insertion is done at the end and deletion is done from the front of the queue. Queue is called First in first out (FIFO) data structure. Whenever an element is added to the queue, the value of REAR is increased by 1. Whenever an element is deleted from the queue, the value of FRONT is increased by 1. The elements are deleted from the queue from the end and front. The elements are inserted in the queue from the end called rear. Queue is useful in the single processor system where only one user at a time can be serviced.

The queue can be implemented in two ways-Queue as an array called static queue and queue as a linked list called dynamic queue. An array is a static data structure. Therefore, by using an array, a queue of fixed size is implemented. The linked list implementation of a queue is done by linking the nodes together to form a chain.

If the first element is added to the queue, then both front and rear are increased by 1. Otherwise for every new insertion of element, only the value of rear is increased by 1. Whenever an item is deleted from the queue, the value of the front is increased by 1.

Initially, the values of front and rear are initialize with -1 because the first element is stored in the array at the zero index.

To Access the full content, Please Purchase

  • Q1

    Name the data structures used to implement a queue.

    Marks:1
    Answer:

    Data structure used to implement a queue are:
    1. Arrays
    2. Linked-List

    View Answer
  • Q2

    Give some real life applications of queue?

    Marks:1
    Answer:

    Queue is very common in real life. We can see its application around us. Some of these are:
    · Ticket counter
    · Vehicles at filling stations
    · Bullet in a machine gun
    · Requests handling in resource sharing system

    View Answer
  • Q3

    What are the basic operations performed on a queue?

    Marks:1
    Answer:

    Basic operations performed on queue are:
    1. Enqueue
    2. Dequeue
    3. isEmpty
    4. isFull

    View Answer
  • Q4

    What do you mean by FIFO? How data structure queue is FIFO structure?

    Marks:1
    Answer:

    FIFO stands for First In First Out, i.e., the one who comes first will get services first and will be released or removed first, e.g., ticket counter.

    Queue follows FIFO structure as the item that is inserted first is removed first.

    View Answer
  • Q5

    What is queue? Explain in brief.

    Marks:1
    Answer:

    A queue is an ordered collection of items from which items can be deleted at one end (known as FRONT) and can be inserted at the other end (known as REAR).

    View Answer