Queue
Queue
QUEUE
CC214 - DATA STRUCTURES AND ALGORITHMS
Coding School 2023
QUEUE
• A queue follows the First In, First Out
(FIFO) principle, making it a
fundamental data structure.
• It's a collection where new elements
are added and existing ones are
removed at opposite ends.
• The addition end is called the rear, and
the removal end is called the front.
Coding School
Operations of queue
• enqueue (Insert): Adds an element to the rear of
the queue.
• dequeue (Remove): Removes the element from
the front of the queue.
• front: Retrieves the element at the front of the
queue without removing it.
• rear: Retrieves the element at the rear of the
queue without removing it.
• is_empty: Checks if the queue is empty.
Coding School
Applications of Queue
• Job scheduling in operating systems involves
using queues to manage and schedule processes
or tasks.
• Print Queue: In a printing system, print jobs are
often placed in a queue.
• Task Management in Operating Systems: Queues
are used to manage tasks or threads in various
operating systems
• Breadth-First Search (BFS): Queues are
fundamental in graph algorithms like BFS.
• Buffer Management: In computer networking,
queues are used for buffering data packets.
Coding School
Applications of Queue(cont...)
Applications of Queue(cont...)
TYPPES OF
QUEUES
• Linear
• Circular
• Deque
• Priority
• Multiple
Coding School
Linea Queue
• A linear queue, a fundamental type in
computer science, adheres to the First In,
First Out (FIFO) principle.
• It's a basic data structure with elements
arranged sequentially.
• In a linear queue, elements are inserted
at one end and dequeued from the
opposite end.
Coding School
Linear Queue
Coding School
Circular Queue
• A circular queue, or circular buffer, is a
queue data structure where the last
element is connected to the first, creating
a circular arrangement.
• In a circular queue, elements form a
circle, and two pointers, front and rear,
manage positions for enqueue and
dequeue operations.
Coding School
Circular Queue
Coding School
Priority Queue
• A priority queue is a data structure in which
each element is assigned a priority.
• The priority of the element will be used to
determine the order in which the elements will
be processed.
Coding School