|
|
@@ -36,12 +36,21 @@ def merge_sort(z: AlgoDatArray, storage: AlgoDatArray, left: int, right: int): |
|
|
|
if __name__ == "__main__": |
|
|
|
filename = "../../seq3.txt" |
|
|
|
dummy = read_int_sequence("../../seq3.txt") |
|
|
|
for right_end in range(1, len(dummy), len(dummy)//100): |
|
|
|
n = len(dummy) |
|
|
|
step = n // 100 |
|
|
|
|
|
|
|
memory_values = [] |
|
|
|
compare_values = [] |
|
|
|
|
|
|
|
for right_end in range(1, n, step): |
|
|
|
AlgoDatValue.reset() |
|
|
|
z = read_int_sequence_limited(filename, right_end) |
|
|
|
storage = AlgoDatArray(z.size) |
|
|
|
merge_sort(z, storage, 0, right_end-1) |
|
|
|
plt.plot([right_end], [AlgoDatValue.memory], 'bo') |
|
|
|
plt.plot([right_end], [AlgoDatValue.compare], 'ro') |
|
|
|
memory_values.append(AlgoDatValue.memory) |
|
|
|
compare_values.append(AlgoDatValue.compare) |
|
|
|
|
|
|
|
plt.show() |
|
|
|
plt.plot(range(1, n, step), memory_values, 'b', label='Memory') |
|
|
|
plt.plot(range(1, n, step), compare_values, 'r', label='Compare') |
|
|
|
plt.legend() |
|
|
|
plt.show() |