Question
TimingPlot.py Generate a series of x (number of items to sort) and y (time to sort) data using the above algorithm. Use randomly sorted lists.
TimingPlot.py Generate a series of x (number of items to sort) and y (time to sort) data using the above algorithm. Use randomly sorted lists. For instance, to generate a list of 100 random integers, you might write: import random n = 100 L = [random.randint(0, n) for i in range(n)] Fit that data (n vs time) with the linear and quadratic functions. Choose n such that you can clearly see the expected shape of the curve. Generate a figure with three curves: a scatter plot of the raw data - a line of best fit with lin a line of best fit with quad Follow best practices when presenting data: Scale your data so the axes numbers are between 1 and 1000 Indlude axis labels with units - Label each curve clearly, either with a textbox on the figure or a legend Save your figure as \"bestfit.png\" We are purposfully giving you flexibility here - how should you generate the lists as n grows? How should you time the functions? You solved a very similar problem in lab; try to apply those techniques here. Note that we will manually grade the final plot, and that you produced the data appropriately. Bad-faith attempts (like arbitrarily generating numbers for your times) will not recieve any credit on this assignment. Include all code you use to generate data and the figures. Submitting At a minimum, submit the following files: . Fitting.py const() lin() quad() . fit_data() TimingPlot.py bubble_sort() whatever functions you use to generate timing data bestfit.png Also submit any other files you mayu use to generate data or the final figure. Students must submit to Mimir individually by the due date (typically, the Wednesday after this module at 11:59 pm EST) to receive credit. Grading Auto Graded 40 - data fitting functionality Manually Graded 30 - TimingPlot.py generates time vs n data appropriately and times functions correctly 30 - \"bestfit.png\" figure def const(x, a): # constant function return a def lin(x, a, b): # linear function a return a * x + b def quad(x, a, b, c): # quadratic function return a * (x ** 2) + b * x + c
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