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.

bin_tree_plot.py 958B

5 months ago
123456789101112131415161718192021222324252627282930
  1. from SoSe24.algodat.foundation import AlgoDatArray, AlgoDatValue, read_int_sequence, read_int_sequence_limited
  2. import matplotlib
  3. matplotlib.use('TkAgg')
  4. import matplotlib.pyplot as plt
  5. import bin_tree as bt
  6. if __name__ == "__main__":
  7. filename = "../../seq3_sorted.txt"
  8. #filename = "../../seq3.txt"
  9. dummy = read_int_sequence(filename)
  10. n = len(dummy)
  11. step = n // 100
  12. memory_values = []
  13. compare_values = []
  14. for right_end in range(1, n, step):
  15. AlgoDatValue.reset()
  16. z = read_int_sequence_limited(filename, right_end)
  17. tree = bt.BinTree()
  18. for i in z:
  19. tree.insert(i)
  20. memory_values.append(AlgoDatValue.memory)
  21. compare_values.append(AlgoDatValue.compare)
  22. print(right_end, AlgoDatValue.compare)
  23. plt.plot(range(1, n, step), memory_values, 'b', label='Memory')
  24. plt.plot(range(1, n, step), compare_values, 'r', label='Compare')
  25. plt.legend()
  26. plt.show()