Question
Implement a class StatQueue (inherit from the class LinkedQueue in the Python file linked_queue.py) to support additional operations, including min(), max(), and mean(), which return
Implement a class StatQueue (inherit from the class LinkedQueue in the Python file linked_queue.py) to support additional operations, including min(), max(), and mean(), which return the minimum, maximum, and mean values of the elements in the queue, respectively. Assume the elements in the queue are numbers. These above operations should run in a constant time; this means that you should maintain corresponding member variables to store minimum, maximum and mean element values (you can name them _min, _max, and _mean respectively). These member variables should be updated each time either when dequeue or enqueue operation are performed. Such that the operations dequeue() and enqueue(e) should be rewrote in the StatQueue class to support updating these member variables. The StatQueue class should continue supporting all other regular operations, such as first(), len(), and is_empty(), by inheriting them from the LinkedQueue class without further implementation.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started