Question: I need help with this Python program: Create a Python program that will measure the execution time of your Bubble Sort code for varying problem
I need help with this Python program:
Create a Python program that will measure the execution time of your Bubble Sort code for varying problem sizes, using Python Lists, Python Arrays, and NumPy arrays for all problem sizes, and plot the results of all three sets of timings in one 3-variable bar chat using Matplotlib.pyplot.
This assignment code must have 3 new functions: one that does the problem setup and timings with Python Lists, another for Python Arrays, and one for NumPy arrays. All variables needed by the functions must be passed in as arguments, and the resulting timings data should be returned to the caller as a Python List. Under no circumstances should you use any global variables inside any of your functions. Your source code should be organized so that the documentation header appears first, followed by function definitions, followed by your main program.
Create 3 new Python functions that:
1. Run the problem set with Python Lists, and return the timings as a Python List.
2. Run the problem set with Python Arrays, and return the timings as a Python List.
3. Run the problem set with NumPy arrays, and return the timings as a Python List.
The argument list for each of these three functions should be identical: the same arguments are needed by all three functions to set up the List, Array, or NumPy array, fill it with random numbers, sort it while measuring elapsed timing, and returning the timing results to the caller.
Problem sizes:
For development and testing, please use N=[128, 256, 512, 1024, 2048, 4096] for your problem sizes.
For the "actual homework runs", please use N=[128, 256, 512, 1024, 2048, 4096, 8192, 16384] as your problem sizes. (The 8K run could take 6-10 seconds, and the 16K run could take 30-60 seconds.)
Creating Lists/Python Arrays/NumPy arrays to be sorted:
Use the Python random module and a hard-coded seed value to generate random numbers in the range [0..9999].
Measuring Runtime Performance
Use the Python time module to "look at the clock" immediately before calling your Bubble Sort function, and again immediately afterwards. Accumulate the elapsed time, measured as the difference of these two clock readings, into a separate Python List. Each of the three new functions (Lists, Python Arrays, NumPy arrays) will build a List of timings and return them back to the caller (the main program code).
Visualization of Runtime Performance
Use Python's matplotlib.pyplot module to generate a 3-variable bar chart showing groups of bars at each problem size on the x-axis and runtime in milliseconds on the y-axis. Your chart should have a meaningful text title as part of the chart. The plot should include x-axis and y-axis labels that indicate what we're looking at, and use custom x-axis tick marks and labels, and a plot legend.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
