STUDENT: RASUL AHMADOV TEACHER: AHMAD AHMADZADA UNIVERSITY: ASOIU FACULTY: SABAH GROUPS GROUP: 692.20ES TOPIC: DATA STRUCTURE QUEUE Queue Data Structure With python code examples 01 Introduction Queues are an essential data structure for managing data in a First-In-FirstOut (FIFO) manner. In this presentation, we will explore the concept of queues, their operations, and implement them using Python code examples. 02 What is a Queue? • • • A Queue is a linear data structure that follows the FIFO principle. Elements are inserted at the rear (enqueue) and removed from the front (dequeue). It operates on the basis of three primary operations: enqueue, dequeue, and peek. 03 Queue Operations • • • • Enqueue: Add an element to the rear of the queue. Dequeue: Remove an element from the front of the queue. Peek: Retrieve the element at the front of the queue without removing it. These operations help maintain the order of elements in the queue. 04 Queue Implementation in Python • • • Python provides different ways to implement a queue, but we will focus on two common approaches: Using a list (Python's built-in data structure) Using the collections module 05 Queue Implementation : Using a List Python lists are dynamic arrays that can be used to implement a queue. • We can use the append() method to enqueue an element. • To dequeue, we can use the pop() method with an index of 0. Let's look at a code example: • Example on Google Colab: 06 Queue Implementation : Using the collections Module • • Python's collections module provides the deque class, which can be used to implement a queue efficiently. The deque class provides methods such as append() and popleft() for enqueue and dequeue operations, respectively. Example on Google Colab: 07 Time Complexity Analysis • • The time complexity of enqueue and dequeue operations in both implementations is O(1). The B implementation using the collections module provides better performance for large queues due to optimized memory management. 08 Additional Queue Operations • • • • Besides the fundamental operations, queues may support other useful operations: Size: Get the current number of elements in the queue. IsEmpty: Check if the queue is empty. These operations help in managing and monitoring the queue efficiently. Thanks! CREDITS: This presentation template was created by Slidesgo, including icons by Flaticon, infographics & images by Freepik