Merge Sort

This commit is contained in:
Oliver Hofmann 2025-04-01 22:06:34 +02:00
parent 7ced5ed336
commit 32190dc104

View File

@ -3,6 +3,7 @@ from utils.memory_cell import MemoryCell
from utils.memory_manager import MemoryManager from utils.memory_manager import MemoryManager
from utils.memory_range import mrange from utils.memory_range import mrange
from utils.literal import Literal from utils.literal import Literal
from time import perf_counter as pfc
@ -82,4 +83,8 @@ def swap(z: MemoryArray, i: int, j: int):
if __name__ == '__main__': if __name__ == '__main__':
analyze_complexity(merge_sort, [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) analyze_complexity(merge_sort, [10, 20, 30, 40, 50, 60, 70, 80, 90, 100])
# analyze_complexity(merge_sort, [10, 20, 30, 40, 50, 60, 70, 80, 90, 100], True) for filename in ["data/seq0.txt", "data/seq1.txt", "data/seq2.txt", "data/seq3.txt"]:
print(filename)
start = pfc()
print(sort_file(filename, merge_sort))
print(f"Dauer: {pfc() - start:.4f}s")