Print('No element present in the demo circular queue')įor i in range(self.head, self.tail 1): Print('The demo circular queue is empty\n') # Remove an element from the demo circular queue Print('The demo circular queue does not have more space\n') If ((self.tail 1) % self.a = self.head): # Add an element into the demo circular queue we can add the new element at the first position. In the circular queue data structure, the last element of the queue is assigned as the first element of a queue to make a circular link between the items i.e. # Add the above method to insert the element In the simple queue data structure, the insertion of the element takes place at the rear and removes from the front position. the issue which occurs first will be resolved first. If any issue occurs, it can be resolved in the FIFO order i.e.If we relate it with the real-world example then, the call center is one of the powerful examples of a queue.It serves the request on a single shared resource.The second person or the thing cannot use the resources until the first person or thing releases that resource. The queue data structure is used when we want to organize the group of objects in a particular order. It is a non-linear data structure that takes a large amount of memory when compared to linear data structures.It is not easy to delete the elements from the middle.Can add the new element any time in the end.Easy to insert or delete the elements in the queue.It is easy to implement as it follows the FIFO principles.The Python queue works on the above principle. Here the first person will buy the ticket first and only then the turn will come for the second person. The second person cannot break the queue to buy the ticket first. The second person or the third person will buy the ticket only if the first person or second person gets the ticket from the counter. While buying the tickets for the movie, people stand in a queue at the ticket counter. Let us understand the queue with the real-world example of “ Cinema ticket counter ”.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |