0% found this document useful (0 votes)
17 views3 pages

Queues Revision Notes

A Queue is a linear data structure that operates on a FIFO basis, with enqueue and dequeue operations occurring at the rear and front, respectively. There are various types of queues including Simple, Circular, Priority, and Double-Ended Queues, each serving different purposes and operations. Queues are commonly used in real-life scenarios such as task scheduling and managing resources.

Uploaded by

Metilda Mervina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views3 pages

Queues Revision Notes

A Queue is a linear data structure that operates on a FIFO basis, with enqueue and dequeue operations occurring at the rear and front, respectively. There are various types of queues including Simple, Circular, Priority, and Double-Ended Queues, each serving different purposes and operations. Queues are commonly used in real-life scenarios such as task scheduling and managing resources.

Uploaded by

Metilda Mervina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Queues in Python - Quick Revision Notes

What is a Queue?

- A Queue is a linear data structure that follows the FIFO (First-In-First-Out) principle.

- Enqueue (add) happens at the rear, and Dequeue (remove) happens at the front.

- Used in real-life scenarios like:

- People standing in line

- Printer job queues

- OS task scheduling

Basic Queue Characteristics

- Maintains order of processing.

- Two pointers: Front (start), Rear (end).

- Python list implementation:

q = []

q.append('apple')

q.append('banana')

print(q.pop(0)) # Output: apple


Types of Queues

1. Simple / Linear Queue

- Elements are added at the rear and removed from the front.

- Examples: Ticket counters, printer queues.

Operations:

- Enqueue: Add to rear

- Dequeue: Remove from front

2. Circular Queue

- End of the queue is connected to the front.

- Efficient use of memory.

- Used in CPU scheduling, memory management.

Operations:

- Enqueue

- Dequeue

- Is Full

- Is Empty

3. Priority Queue

- Each element has a priority.

- Higher priority elements are processed first.

- Used in OS task scheduling, network scheduling.

Operations:

- Insertion (at correct position)

- Deletion (highest priority)


- Peek (view highest priority)

4. Double-Ended Queue (Deque)

- Add/remove items from both ends.

- No FIFO or LIFO restriction.

Operations:

- Add/Remove from front and rear

You might also like