forked from hofmannol/AlgoDatSoSe25
Quick Sort and Heap Sort
This commit is contained in:
parent
27a37037d1
commit
1af49ede8c
@ -21,9 +21,7 @@ def merge_sort_stepwise(z: MemoryArray, l: Literal = None, r: Literal = None, bu
|
||||
yield from merge(z, l, m, r, buffer)
|
||||
|
||||
def merge(z: MemoryArray, l: Literal, m: Literal, r: Literal, buffer: MemoryArray):
|
||||
i = MemoryCell(l)
|
||||
j = MemoryCell(m.succ())
|
||||
k = MemoryCell(l)
|
||||
with MemoryCell(l) as i, MemoryCell(m.succ()) as j, MemoryCell(l) as k:
|
||||
while i <= m and j <= r:
|
||||
if z[i] <= z[j]:
|
||||
buffer[k].set(z[i])
|
||||
@ -51,7 +49,6 @@ def merge_sort(z: MemoryArray):
|
||||
next(sort_generator)
|
||||
except StopIteration:
|
||||
break
|
||||
# print(len(z), z.count_compares(), MemoryManager.get_instance().count_compares())
|
||||
|
||||
def sort_file(filename, sort_func):
|
||||
z = MemoryArray.create_array_from_file(filename)
|
||||
|
Loading…
x
Reference in New Issue
Block a user