# Queue Basics

  • Queue is a linear data structure which follows FIFO i.e. First-In-First-Out method.

  • That is the data/element which is stored first in the queue will be accessed first.

  • The two ends of a queue are called Front and Rear.

  • Insertion takes place at the Rear and the elements are accessed or removed from the Front.

  • Suppose we take an example of people standing in a queue at an ATM, then the person at front will access the ATM first and then the second person and so on.

  • Any new person coming will join the queue at the end i.e rear.

  • Applications of queues in computer world :

    1. Scheduling : CPU Scheduling , Job Scheduling.
    2. Buffers : I/O Buffers.
  • Example: Printer schedules all the jobs in a queue and prints them one by one.

  • Operations

    1. enqueue() : Insertion of new element in queue.
    2. dequeue( : Removal of element at front from queue.
    3. showfront() : To show the element at front.
    4. isempty() : To check if queue is empty.