Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Queue Data Structure: Last Updated: 11 May, 2024

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

6/29/24, 6:37 PM Queue Data Structure - GeeksforGeeks

TutorialsDSAData ScienceWeb TechCourses

DSA Data Structures Array String Linked List Stack Queue Tree Binary Tree Binary Sea

Queue Data Structure


Last Updated : 11 May, 2024
A Queue Data Structure is a fundamental concept in computer science
used for storing and managing data in a specific order. It follows the
principle of “First in, First out” (FIFO), where the first element added
to the queue is the first one to be removed. Queues are commonly
used in various algorithms and applications for their simplicity and
efficiency in managing data flow.

Queue Data Structure

Table of Content
What is Queue in Data Structures?
Basic Operations of Queue Data Structure
Applications of Queue
Basics of Queue Data Structure
Implementations of Queue in various Programming Languages
Other Implementations of Queue Data Structure
Easy Problems on Queue Data Structure
Medium Problems on Queue Data Structure
Hard Problems on Queue Data Structure

https://www.geeksforgeeks.org/queue-data-structure/?ref=lbp 1/7
6/29/24, 6:37 PM Queue Data Structure - GeeksforGeeks

What is Queue in Data Structures?


A queue is a linear data structure that follows the First-In-First-Out
(FIFO) principle. It operates like a line where elements are added at
one end (rear) and removed from the other end (front).

Basic Operations of Queue Data Structure


Enqueue (Insert): Adds an element to the rear of the queue.
Dequeue (Delete): Removes and returns the element from the front
of the queue.
Peek: Returns the element at the front of the queue without
removing it.
Empty: Checks if the queue is empty.
Full: Checks if the queue is full.

Applications of Queue
Task scheduling in operating systems
Data transfer in network communication
Simulation of real-world systems (e.g., waiting lines)
Priority queues for event processing queues for event processing

Implementation of Queues
Queues can be implemented using Two techniques:

Implementations of Queue Data Structure using Arrays


Implementations of Queue Data Structure using Linked List

Basics of Queue Data Structure


Introduction to Queue – Data Structure and Algorithm Tutorials
Basic Operations of Queue Data Structure
Different Types of Queue
Applications, Advantages and Disadvantages of Queue

Implementations of Queue in various Programming


Languages
Queue in C++ Standard Template Library (STL)
https://www.geeksforgeeks.org/queue-data-structure/?ref=lbp 2/7
6/29/24, 6:37 PM Queue Data Structure - GeeksforGeeks

Queue Interface In Java


Queue In Python
Queue In C#
Queue in Javascript

Other Implementations of Queue Data Structure


Implementation of Deque using doubly linked list
Implement a stack using single queue
Implement Queue using Stacks
How to efficiently implement k Queues in a single array?
LRU Cache Implementation

Easy Problems on Queue Data Structure


Implement Stack using Queues
Detect cycle in an undirected graph using BFS
Breadth First Search or BFS for a Graph
Traversing directory in Java using BFS
Vertical order traversal of Binary Tree using Map
Print Right View of a Binary Tree
Find Minimum Depth of a Binary Tree
Check whether a given graph is Bipartite or not

Medium Problems on Queue Data Structure


Flatten a multilevel linked list
Level with maximum number of nodes
Find if there is a path between two vertices in a directed graph
Print all nodes between two given levels in Binary Tree
Find next right node of a given key
Minimum steps to reach target by a Knight
Islands in a graph using BFS
Level order traversal line by line | Set 3 (Using One Queue)
Find the first non-repeating character from a stream of characters

Hard Problems on Queue Data Structure


Sliding Window Maximum (Maximum of all subarrays of size K)
https://www.geeksforgeeks.org/queue-data-structure/?ref=lbp 3/7
6/29/24, 6:37 PM Queue Data Structure - GeeksforGeeks

Flood Fill Algorithm


Minimum time required to rot all oranges
Shortest path in a Binary Maze
An Interesting Method to Generate Binary Numbers from 1 to n
Maximum cost path from source node to destination
Shortest distance between two cells in a matrix or grid
Snake and Ladder Problem
Find shortest safe route in a path with landmines
Count all possible walks from a source to a destination with exactly
K edges
Minimum Cost of Simple Path between two nodes in a directed and
weighted graph
Minimum Cost Path in a directed graph via given set of intermediate
nodes
Find the first circular tour that visits all petrol pumps

Quick Links:

‘Practice Problems’ on Queue


‘Videos’ on Queue
‘Quizzes’ on Queue

Recommended:

Learn Data Structure and Algorithms | DSA Tutorial


Queue in Go Language
Queue in Scala

https://www.geeksforgeeks.org/queue-data-structure/?ref=lbp 4/7
6/29/24, 6:37 PM Queue Data Structure - GeeksforGeeks

H hare…

Next Article
Introduction to Queue Data Structure

Similar Reads
Should we declare as Queue or Priority Queue while using Priority…
Queue: Queue is an Interface that extends the collection Interface in Java
and this interface belongs to java.util package. A queue is a type of dat…
3 min read

Static Data Structure vs Dynamic Data Structure


Data structure is a way of storing and organizing data efficiently such
that the required operations on them can be performed be efficient wit…
4 min read

Applications of Queue Data Structure


Introduction : A queue is a linear data structure that follows the "first-in,
first-out" (FIFO) principle. It is a collection of elements that supports tw…
5 min read

Basic Operations for Queue in Data Structure


Basic Operations on Queue: Some of the basic operations for Queue in
Data Structure are: enqueue() - Insertion of elements to the…
11 min read

Top 50 Problems on Queue Data Structure asked in SDE Interviews


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. We…
https://www.geeksforgeeks.org/queue-data-structure/?ref=lbp 5/7
6/29/24, 6:37 PM Queue Data Structure - GeeksforGeeks
3 min read

View More Articles

Article Tags : DSA Queue

Practice Tags : Queue

A-143, 9th Floor, Sovereign Corporate


Tower, Sector-136, Noida, Uttar Pradesh -
201305

Company Languages
About Us Python
Legal Java
In Media C++
Contact Us PHP
Advertise with us GoLang
GFG Corporate Solution SQL
Placement Training Program R Language
GeeksforGeeks Community Android Tutorial
Tutorials Archive

DSA Data Science & ML


Data Structures Data Science With Python
Algorithms Data Science For Beginner
DSA for Beginners Machine Learning Tutorial
Basic DSA Problems ML Maths
DSA Roadmap Data Visualisation Tutorial
Top 100 DSA Interview Problems Pandas Tutorial
DSA Roadmap by Sandeep Jain NumPy Tutorial
All Cheat Sheets NLP Tutorial
Deep Learning Tutorial

Web Technologies Python Tutorial


https://www.geeksforgeeks.org/queue-data-structure/?ref=lbp 6/7
6/29/24, 6:37 PM Queue Data Structure - GeeksforGeeks
HTML Python Programming Examples
CSS Python Projects
JavaScript Python Tkinter
TypeScript Web Scraping
ReactJS OpenCV Tutorial
NextJS Python Interview Question
Bootstrap Django
Web Design

Computer Science DevOps


Operating Systems Git
Computer Network Linux
Database Management System AWS
Software Engineering Docker
Digital Logic Design Kubernetes
Engineering Maths Azure
Software Development GCP
Software Testing DevOps Roadmap

System Design Inteview Preparation


High Level Design Competitive Programming
Low Level Design Top DS or Algo for CP
UML Diagrams Company-Wise Recruitment Process
Interview Guide Company-Wise Preparation
Design Patterns Aptitude Preparation
OOAD Puzzles
System Design Bootcamp
Interview Questions

School Subjects GeeksforGeeks Videos


Mathematics DSA
Physics Python
Chemistry Java
Biology C++
Social Science Web Development
English Grammar Data Science
Commerce CS Subjects
World GK

@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved

https://www.geeksforgeeks.org/queue-data-structure/?ref=lbp 7/7

You might also like