Question: 1 . Create a new file hw 1 1 . py . 2 . Add a docstring with your name and surname on top. 3

1. Create a new file hw11.py.
2. Add a docstring with your name and surname on top.
3. Copy all sorting functions from the lecture code (lines 6-77) file Sorting.py.
4. Install Matplotlib:
- To install Matplotlib, you can use the following command in your terminal or command prompt, depending on your Python environment. Open your terminal or command prompt and type:
pip install matplotlib
This command uses the Python package manager pip to download and install the Matplotlib library. Make sure you have a working internet connection, and the installation should proceed without any issues.
- The following code gives an EXAMPLE how to plot data using Matplotlib library.
```
import matplotlib.pyplot as plt
# Sample data
x =[1,2,3,4,5]
y =[2,4,6,8,10]
z =[3,5,7,9,11]
# Create a simple line plot
plt.plot(x, y, label='y')
plt.plot(x, z, label='z')
# Add labels to the plot
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
# Add legend to the plot
plt.legend()
# Add a title to the plot
plt.title('Simple Plot in Python')
# Display the plot
plt.show()
```
5. Write a function random_list that takes a parameter \( n \) and generates a Python list of size \( n \), containing random numbers in the range between 0 and 10,000(use the random module).
6. In the main function, for each sorting algorithm: - Use the random_list function to generate random lists of integers with the following sizes: 10,100,1,000,5,000, and 8,000.
Note: You must generate new lists for each sorting algorithm because lists in Python are mutable. If you sort a list with one algorithm, the next algorithm would work on an already sorted list.
- Use the time module in Python to measure the running time for each algorithm and list size (import time).
- Measure and record the running time of each sorting algorithm for every list size. Store the running times in a list.
7. Create a plot to visualize the running time of each algorithm with respect to the size of the input list. Your plot should include:
- A title (as shown in the example)
- X-axis label
- Y-axis label
- A legend
8. Example plot for reference:
1 . Create a new file hw 1 1 . py . 2 . Add a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!