Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	SoSe24/lec04_trees/avl_tree.py
#	SoSe24/lec04_trees/b_tree.py
#	SoSe24/lec05_hash/hash_table.py
master
Oliver Hofmann 7 months ago
parent
commit
50cf0b9b52
2 changed files with 33 additions and 2 deletions
  1. 2
    2
      SoSe24/lec03_sort_alg/quick_sort.py
  2. 31
    0
      SoSe24/lec05_hash/hash_plot.py

+ 2
- 2
SoSe24/lec03_sort_alg/quick_sort.py View File

@@ -54,8 +54,8 @@ def median_pivot(z: AlgoDatArray, left: int, right: int) -> int:

def quick_sort(z: AlgoDatArray, left: int, right: int):
if left < right:
q = partition(z, left, right)
#q = median_pivot(z, left, right)
#q = partition(z, left, right)
q = median_pivot(z, left, right)
quick_sort(z, left, q-1)
quick_sort(z, q+1, right)


+ 31
- 0
SoSe24/lec05_hash/hash_plot.py View File

@@ -0,0 +1,31 @@
from SoSe24.algodat.foundation import AlgoDatArray, AlgoDatValue, read_int_sequence, read_int_sequence_limited
import matplotlib
import matplotlib.pyplot as plt
import hash_table as ht

if __name__ == "__main__":
filename = "../../seq3.txt"
dummy = read_int_sequence(filename)
n = len(dummy)
step = n // 100

memory_values = []
compare_values = []
alpha_values = []

for right_end in range(1, n, step):
AlgoDatValue.reset()
z = read_int_sequence_limited(filename, right_end)
hash = ht.HashTable(int(right_end*2), hash_function=ht.h, exploratory_function=ht.f1)
for i in z:
hash.insert(i)
memory_values.append(AlgoDatValue.memory)
compare_values.append(AlgoDatValue.compare)
alpha_values.append(hash.alpha())

plt.plot(range(1, n, step), memory_values, 'b', label='Memory')
plt.plot(range(1, n, step), compare_values, 'r', label='Compare')
plt.plot(range(1, n, step), alpha_values, 'g', label='Alpha')

plt.legend()
plt.show()

Loading…
Cancel
Save