Skip to content
Snippets Groups Projects
Commit 9bcdb4fc authored by nilsl99's avatar nilsl99
Browse files

Added a jupyter notebook for timing

parent 2f8d756a
Branches
No related tags found
No related merge requests found
%% Cell type:code id: tags:
``` python
from Aufgabe02 import HeapSort, InsertionSort, CountingSort
from time import perf_counter_ns as time
import random
import matplotlib.pyplot as plt
```
%% Cell type:markdown id: tags:
# Counting Sort
%% Cell type:code id: tags:
``` python
max_num = 99
num_list = range(max_num + 1)
n_list = [100*i+10 for i in range(100)]
t_list = [0]*len(n_list)
for i, n in enumerate(n_list):
for j in range(10):
array = random.choices(num_list, k=n)
t0 = time()
sorted_array = CountingSort(array, k=max_num)
t1 = time()
t_list[i] += t1 - t0
t_list_ms = [t/1e+6 for t in t_list]
```
%% Cell type:code id: tags:
``` python
fig = plt.figure()
ax = fig.add_subplot(111)
ax.grid("both")
ax.plot(n_list, t_list_ms)
fig.tight_layout()
plt.show()
```
%% Output
%% Cell type:code id: tags:
``` python
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment