1 / 36

Queue In Data Structure | Introduction To Queue With Example | Data Structures T

This presentation on Queue In Data Structure will acquaint you with all the basics of Queue data structure from scratch. In this introduction to queue with example video we will provide you with algorithms of queue operations to make you understand the flow of data. You will also understand the importance of queue data structure through its various applications. So, let's begin!<br><br>The topics covered in this video on Queue in Data Structure are:<br>1. Introduction<br>2. Structure of Queue<br>3. Queue Operation<br>4. Types of Queues and their structures<br>5. Application of Queues<br>

Simplilearn
Download Presentation

Queue In Data Structure | Introduction To Queue With Example | Data Structures T

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. What’s in It for You? Introduction to Queue Data Structure Structure of Queue Queue Operations Types of Queues and Their Structures Applications of Queues

  2. Introduction to Queue Data Structure

  3. Click here to watch the video

  4. At present people rely on messaging applications like WhatsApp, Facebook messenger, and Instagram chats to communicate with friends and family. Introduction to Queue Data Structure

  5. In these messaging applications, the order of messages is maintained for each user. Introduction to Queue Data Structure

  6. How are these applications maintaining the order of text messages? Queues are maintained for each user containing messages to be delivered… Once user connects to network messages in the queue gets delivered!

  7. Structure of Queue

  8. Let’s take an example of a movie ticket counter to understand the structure of queue... Structure of Queue Both the ends are fixed! Open at both ends

  9. Let’s take an example of a movie ticket counter to understand the structure of queue... Structure of Queue Person who enters first receives the movie ticket first Person who enters last will receive the ticket last

  10. The queue is a linear collection of different data types. Both the ends of queue data structure are open allowing it to have different operations at different ends. Structure of Queue FRONT (Deletion) REAR (Insertion) Both the ends remain open Linear collection of different data types The end at which insertion takes place is called REAR. The end at which deletion takes place is known as FRONT.

  11. Structure of queue depends on perspective of programmer. For instance, If left end = FRONT Then right end = FRONT If left end = REAR Then right end = REAR Structure of Queue

  12. Queue Operations

  13. QueueOperations 1 Enqueue() : This operation is used to store the elements in the Queue Dequeue() : This operation is used to remove elements from Queue 2 isFull() : Checks if the Queue is full or not isNull() : Evaluates if the queue is empty 3 4 Peek() : get the element from the front of the Queue without removing it

  14. We will gauge insight of queue operations by performing them on queue one by one: Queue Operations Enqueue(Argument) IsFull() Dequeue() peek() isNull()

  15. Initially, let’s assign some random size to queue. Queue Operations For example, int queue[3]; -1 FRONT REAR

  16. ALGORITHM- Check if the queue is full. If the queue is full, produce overflow error and exit. If the queue is not full, increment REAR pointer to point the next empty space. Add DATA element to the queue location, where the REAR is pointing. Element is added successfully. Enqueue(Arg..) 1. Enqueue(5) Our queue is empty! 5 -1 + 1 = 0 0 FRONT REAR

  17. 2. Enqueue(1) 1 5 Enqueue(Arg..) 0 1 REAR = REAR + 1 REAR = 0 + 1 = 1 REAR FRONT 3. Enqueue(-2) 5 1 -2 1 0 2 REAR REAR= 1 + 1 = 2 FRONT

  18. ALGORITHM- Begin procedure isFull(). If REAR equals to MAXSIZE. Return “Queue is full” Else, Return “Queue is not full”. 4. isFull( ) 5 1 -2 3 integer variables = 12 Bytes! REAR So, let’s say size of our array is 12 bytes. 0 1 2 Thus, output will be “Queue is Full”

  19. ALGORITHM- Check if the queue is empty. If the queue is empty, produce underflow error and exit. If the queue is not empty, access the data where FRONT is pointing. Increment front pointer to point to the next available data. Element is removed successfully. 5. Dequeue( ) Dequeue() This queue is not empty! 5 1 -2 0 1 2 FRONT FRONT REAR

  20. ALGORITHM- Begin procedure Peek(). Check if the queue is empty and return “Queue is Empty”. If the queue is not empty, access DATA from FRONT node. End of procedure Peek. 6. Peek( ) This queue is not empty. -2 1 1 2 Data will be accessed with temporary variable! FRONT REAR

  21. 7. Dequeue() -2 1 Dequeue( ) 2 1 FRONT REAR FRONT = 1 + 1 = 2 8. Dequeue() -2 2 FRONT and REAR both will point to null now FRONT REAR

  22. ALGORITHM- Begin procedure isEmpty(). If FRONT is equal to NULL (-1 as per our convention). Return “Queue is Empty”. End of procedure Peek. 9. isEmpty( ) -1 OUTPUT : Queue is Empty FRONT

  23. Types of Queues

  24. Types of Queues

  25. Linear queue 1. 1. The queue structure we have discussed till the time is known as linear or simple queue. 2. 2. 3. 3. FRONT REAR 4. 4.

  26. Circular queue 1. 1. Last node of this queue is connected to the first node making circular link. That is why it is also called as Ring Buffer. Circular queue is better version of linear queue. 2. 2. 3. 3. Circular link 5 1 -2 4. 4. First Node Last Node

  27. Priority queue 1. 1. A priority queue is another special type of Queue data structure in which each element has some priority assigned with it. 2. 2. In priority queue, insertion occurs based on the arrival and deletion occurs according to the priority. 3. 3. REAR Node FRONT Node 4. 4. Least element Largest element ENQUEUE DEQUEUE In this queue priority of elements is dependent on their order.

  28. Double ended queue 1. 1. Deque is a linear data structure in which the insertion and deletion operations are performed from both ends. Deque can be used as stack as well as Queue as it allows the insertion and deletion operations on both ends. 2. 2. REAR 3. 3. FRONT REAR 4. 4. If insertion happens at one end and deletion at another then that deque will be considered as queue. If both insertion and deletion happens at one end then that deque will be considered as stack.

  29. Applications of Queues

  30. Queues in Operating Systems Applications of Queues While using multiple applications, Dead-lock occurs in the system leading to response delay. At that instance, OS utilize queues to maintain multiple processes until their execution.

  31. Queues in printers Applications of Queues Queue data structure is used in printers to maintain the order of pages while printing. One after another pages will be removed from queue and will be printed by printer. Pages we want to print in Order, will be stored in the queue.

  32. Queues in software applications Applications of queue Applications like Domino’s, Swiggy and Zomato uses a queue for maintaining food order status. Once your order-ID reaches front of the queue, then Delivery will be processed! When you place an order from online portal, your Order-ID enters the queue

  33. Final Key Take-Aways

  34. Final Key Take-Aways The operations that allows manipulation Of data are Enqueue and dequeue. Used to serve purpose of FCFS There are four types of queues. Can handle multiple data-types Queue is a linear data structure.

More Related