0% found this document useful (0 votes)
63 views

Queues in Python

Notes for python
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

Queues in Python

Notes for python
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Queues in Python

1
A Queue is a linear data structure that
Definition of follows the First In First Out (FIFO)
principle. Elements are added from one
Queue end, known as the rear, and removed
from the other end, known as the front.

2
Consider a queue of people
waiting in line for a ticket. The
person who arrives first gets
Example: served first, and the person
who arrives last will be served
last.

3
Types of
Queues
4
Simple queue
Types of
QUEUE Circular queue

Priority of queue

Doubly ended queue

Queue with Linked List

5
Simple
queue
A simple queue, also
known as a linear queue, is a
straightforward data structure
that operates on the principle
of FIFO(First In, First Out).
Elements are inserted at the
rear end and removed from
the front end.

6
Circular Queue

• In a circular queue, the last element is connected to the first element, forming
a circular structure that aids in efficient space utilization.

7
Priority Queue

• A priority queue assigns a priority to each element, ensuring that elements


with higher priority are dequeued before those with lower priority.

8
Double-ended Queue (Deque)

• A deque allows insertion and deletion of elements from both the front and
rear, offering flexibility in managing data.

9
Queue with Linked List

• This queue is built using a linked list, where each element points to the next,
enabling dynamic memory allocation and efficient data manipulation.

10
Queue Implementation in Python

11
Our competition

• Our product is priced below that of • Company A product is more


other companies on the market expensive
• Design is simple and easy to use, • Companies B & C product is
compared to the complex designs of expensive and inconvenient to use
the competitors • Companies D & E product is
• Affordability is the main draw for our affordable, but inconvenient to use
consumers to our product

12
Queue Implementation in Python

from collections import deque


# Creating a Queue
queue = deque()
# Adding elements to the Queue
queue.append('A')
queue.append('B')
queue.append('C')
# Removing elements from the Queue
queue.popleft() # Removes 'A'
queue.popleft() # Removes 'B' 13
Thank you Awikang,
GROUP 3
Rachiel

Taguitag, Lutwache
Jojo n, Karylle

Buyacao,
Daskeo,
Sean
Aliyaj
Francis

You might also like