Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Download and save labb_efficiency.py and terminalplot.py. (Save in the same folder as your queue.py from Exercise 1.) In this file, both your Bounded and
1. Download and save labb_efficiency.py and terminalplot.py. (Save in the same folder as your queue.py from Exercise 1.) In this file, both your Bounded and Circular Queues have been imported from queues.py. This file also contains 4 function definitions: 3 have already been completed for you (enqueue experiment, average dequeue_experiment, and main). Read through the comments of those 3 functions to understand what they are doing. 2. Complete the function de queue_experiment (queue) so that it removes the first item in the queue, and continues to do so until that queue is empty. Note that the queue is passed in as an input to the function - so you do NOT have to create it or fill it with data in this function. Use a function from either the time or timeit modules to measure how long it takes to dequeue all of the items in the queue, and return that time measurement. Hint: there is an example of how to use time.time() at the bottom of lab6 efficiency.py. The time module returns times in seconds. import time start = time.time ( # The statement(s) that you want to test end = time.time () time_interval = end - start 3. Run lab6_efficiency. (This may take some time to run.) This will run a number of experiments, measuring the time it takes to dequeue all items from Bounded and Circular Queues of increasing capacities. These times will be printed in a table for you to view. The data should also be plotted for you, with time on the y-axis, and n on the x-axis (where n is the number of dequeues made). If a plot is not displayed i.e. if you see a message that says **Not able to print graph. Continuine..."), not the data from that ... 1. Download and save labb_efficiency.py and terminalplot.py. (Save in the same folder as your queue.py from Exercise 1.) In this file, both your Bounded and Circular Queues have been imported from queues.py. This file also contains 4 function definitions: 3 have already been completed for you (enqueue experiment, average dequeue_experiment, and main). Read through the comments of those 3 functions to understand what they are doing. 2. Complete the function de queue_experiment (queue) so that it removes the first item in the queue, and continues to do so until that queue is empty. Note that the queue is passed in as an input to the function - so you do NOT have to create it or fill it with data in this function. Use a function from either the time or timeit modules to measure how long it takes to dequeue all of the items in the queue, and return that time measurement. Hint: there is an example of how to use time.time() at the bottom of lab6 efficiency.py. The time module returns times in seconds. import time start = time.time ( # The statement(s) that you want to test end = time.time () time_interval = end - start 3. Run lab6_efficiency. (This may take some time to run.) This will run a number of experiments, measuring the time it takes to dequeue all items from Bounded and Circular Queues of increasing capacities. These times will be printed in a table for you to view. The data should also be plotted for you, with time on the y-axis, and n on the x-axis (where n is the number of dequeues made). If a plot is not displayed i.e. if you see a message that says **Not able to print graph. Continuine..."), not the data from that
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