You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hash_plot.py 1.0KB

12345678910111213141516171819202122232425262728293031
  1. from SoSe24.algodat.foundation import AlgoDatArray, AlgoDatValue, read_int_sequence, read_int_sequence_limited
  2. import matplotlib
  3. import matplotlib.pyplot as plt
  4. import hash_table as ht
  5. if __name__ == "__main__":
  6. filename = "../../seq3.txt"
  7. dummy = read_int_sequence(filename)
  8. n = len(dummy)
  9. step = n // 100
  10. memory_values = []
  11. compare_values = []
  12. alpha_values = []
  13. for right_end in range(1, n, step):
  14. AlgoDatValue.reset()
  15. z = read_int_sequence_limited(filename, right_end)
  16. hash = ht.HashTable(int(right_end*2), hash_function=ht.h, exploratory_function=ht.f1)
  17. for i in z:
  18. hash.insert(i)
  19. memory_values.append(AlgoDatValue.memory)
  20. compare_values.append(AlgoDatValue.compare)
  21. alpha_values.append(hash.alpha())
  22. plt.plot(range(1, n, step), memory_values, 'b', label='Memory')
  23. plt.plot(range(1, n, step), compare_values, 'r', label='Compare')
  24. plt.plot(range(1, n, step), alpha_values, 'g', label='Alpha')
  25. plt.legend()
  26. plt.show()