#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
Queues

Queue in Data Structure — Types & Algorithms (with Examples)

A Queue is a linear data structure that follows the FIFO (First In, First Out) principle: the first element added is the first one removed.

Core Operations

  • enqueue(item) — insert an element at the rear.
  • dequeue() — remove and return the element at the front.
  • peek() — view the front element without removing it.
  • isEmpty() — check whether the queue has any elements.

Types of Queues

TypeDescription
Simple QueueBasic FIFO queue, insert at rear, remove from front.
Circular QueueRear wraps back to the front to reuse freed space.
Priority QueueElements are served according to priority, not order of arrival.
DequeInsertion and removal allowed at both ends.
from collections import deque

class Queue:
    def __init__(self):
        self.items = deque()

    def enqueue(self, item):
        self.items.append(item)

    def dequeue(self):
        return self.items.popleft()

    def peek(self):
        return self.items[0]

    def is_empty(self):
        return len(self.items) == 0

Complexity

OperationTime
EnqueueO(1)
DequeueO(1)
PeekO(1)

Applications

  • Task and process scheduling in operating systems.
  • Breadth First Search traversal in graphs.
  • Handling of asynchronous data such as I/O buffers and print queues.

Ready to master Data Structures & Algorithms?

Learn DSA hands-on with mentor-led sessions, real interview practice, and placement support.

Explore Course