The Wayback Machine - https://web.archive.org/web/20240204105222/https://www.geeksforgeeks.org/queue-data-structure/
Open In App
Related Articles

Queue Data Structure

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

Learn Data Structures and Algorithms | DSA Tutorial
Learn more about Queue in DSA Self Paced Course
Practice Problems on Queue
Top Quizzes on Queue

What is Queue Data Structure?

A Queue is defined as a linear data structure that is open at both ends and the operations are performed in First In First Out (FIFO) order.

Queue Data Structure

We define a queue to be a list in which all additions to the list are made at one end, and all deletions from the list are made at the other end.  The element which is first pushed into the order, the operation is first performed on that.

FIFO Principle of Queue:

  • A Queue is like a line waiting to purchase tickets, where the first person in line is the first person served. (i.e. First come first serve).
  • Position of the entry in a queue ready to be served, that is, the first entry that will be removed from the queue, is called the front of the queue(sometimes, head of the queue), similarly, the position of the last entry in the queue, that is, the one most recently added, is called the rear (or the tail) of the queue. See the below figure.

Characteristics of Queue:

  • Queue can handle multiple data.
  • We can access both ends.
  • They are fast and flexible. 

Queue Representation:

Like stacks, Queues can also be represented in an array: In this representation, the Queue is implemented using the array. Variables used in this case are

  • Queue: the name of the array storing queue elements.
  • Front: the index where the first element is stored in the array representing the queue.
  • Rear: the index where the last element is stored in an array representing the queue.

Introduction to Queue Data Structure:

Implementation of Queue in various Programming Languages:

Some other Implementations of Queue Data Structure:

Standard Easy Problems on Queue Data Structure:

Standard Medium Problems on Queue Data Structure:

Standard Hard Problems on Queue Data Structure:

Quick Links:

Recommended:


Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!


Last Updated : 24 Jan, 2024
Like Article
Save Article
Share your thoughts in the comments
Similar Reads
Complete Tutorials