QUEUE DATA STRUCTURES

In this blog post will study what is a queue, types, applications, operations and C++ code file for implementation of ordinary queue.

Definition

A queue is an ordered list in which insertions are done at one end (rear) and deletions are done at other end (front).

The first element to be inserted is the first one to be deleted. Hence, it is called First in First out (FIFO).

In queue, the order in which data arrives is important. Generally, a queue is a line of people or things waiting to be served in sequential order starting at the beginning of the line or sequence.

Types

  1. Ordinary Queue
  2. Circular Queue
  3. Priority Queue
  4. Double Ended Queue(Not much used)

We will study the 2nd & 3rd type in seperate blog posts.

Applications

  • Operating systems schedule jobs (with equal priority) in the order of arrival (e.g., printing a document).
  • Simulation of real-world queues such as lines at a ticket counter or any other firstcome first-served scenario requires a queue.
  • Asynchronous data transfer (file IO, pipes, sockets).
  • Used as component for other data structures.
  • Waiting times of customers at call center.

Standard Operations

Do refer the code available the end of this section to understand the following theory.

  1. Enqueue: Insert a new item at the rear end of the queue. If there is no place then queue is in overflow state.
  2. Dequeue: Remove an item from the front end of the queue. If there are no elements then the queue is in underflow state.
  3. isEmpty: To check whether queue is empty or not.
  4. isFull: To check if queue is full or not.
  5. Display Display the items in the queue.

Code file

Please open this in your pc or with a compatible app in your mobile.

C++ Implementation for QUEUE DATA STRUCTURES

That's it from this blog post. If you liked it then do share this blog with your friends or people who wanna get into programming world. Thank You!

Copyright © NStF Blogs 2021