![]() So, what will be the algorithm? #returns max_size of queue The rear will point to the last element inserted in the queue. ![]() Whether there is space left in the queue or not i.e.Now, when you are trying to enqueue elements to the Queue, you have to remember the following points: The front is taken to be 0 initially because it will always point to the first element of the queue.Front indicates the position of the first element in the queue.The rear is initially taken to be -1 because the queue is empty.rear indicates the index position of the last element in the queue.Elements of the queue are stored in the python list.max_size is the maximum number of elements expected in the queue.Now, let’s start via creating class Queue in Python: class Queue: De-queue or remove an element from the front of the queue En-queue or add an element to the end of the queue.Ģ. Call Centre – phone systems will use Queues, to hold people calling them in order, until a service representative is free.Īll of these examples follow First-In-Last-Out strategy.Īpart from the complementary operations, I may say that the main Operations possible on the Queue are:ġ.Vehicles on the toll-tax bridge – The vehicles arriving early leaves first.Luggage checking machine – Checks the Luggage that has been kept first on the conveyer belt.Phone answering system- Person who calls first on your gadget gets attended first.Let’s consider some examples where we se queue type working in daily life: Here, the people are standing one behind the other and they are serviced based on the First-In-First-Out (FIFO) mechanism. So, what will you do? You must have gone to the back and stood behind the last person waiting for the ticket. In the multiplex, the tickets were issued on the First-Come-First-Serve basis and people were standing behind each other waiting for their turn. As you have already studied about the importance of Data Structures in the previous article, Lets dive right in the topic of the article i.e.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |