Question: For this exercise, you will be coding your very first class, a ` Queue ` class. Queues are a fundamental computer science data structure that
For this exercise, you will be coding your very first class, a Queue class.
Queues are a fundamental computer science data structure that imposes specific rules for manipulating the elements it contains.
A queue is basically like a line at Disneyland: You can add elements to the end of the queue, and they maintain a specific order. When you want to remove an element from the queue, you take out the one that has been there the longest this is known as "firstinfirstout", or FIFO
In your Queue class, you are required to implement three methods:
init: to initialize your Queue think: how will you store the queue's elements? You'll need to initialize
an appropriate object attribute in this method
insert: inserts one element in your Queue;
remove: removes one element from your Queue and returns it If the queue is empty, return a message that
says it is empty without throwing an error that halts your code
When you're done, you should test your implementation.
python
queue Queue
queue.insert
queue.insert
queue.remove
queue.insert
queue.remove
queue.remove
queue.remove
Your results should look like this:
The queue is empty
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
