forked from hofmannol/AlgoDatSoSe25
Praktikum 3
This commit is contained in:
parent
27d86de290
commit
081353c6c0
@ -107,6 +107,24 @@ def analyze_complexity_insert(sizes, presorted=False):
|
||||
MemoryManager.plot_stats(["cells", "compares", "writes"])
|
||||
|
||||
|
||||
def analyze_complexity_pop(sizes, presorted=False):
|
||||
"""
|
||||
Analysiert die Komplexität der Pop-Funktion.
|
||||
"""
|
||||
for size in sizes:
|
||||
MemoryManager().purge() # Speicher zurücksetzen
|
||||
pq = PriorityQueue(Literal(size))
|
||||
insert_list = [random.randint(-100, 100) for _ in range(size)]
|
||||
if presorted:
|
||||
insert_list.sort()
|
||||
for insert_value in insert_list:
|
||||
pq.insert(MemoryCell(insert_value))
|
||||
MemoryManager().reset()
|
||||
pq.pop()
|
||||
MemoryManager.save_stats(size)
|
||||
|
||||
MemoryManager.plot_stats(["cells", "compares", "writes"])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
length = Literal(10)
|
||||
@ -128,4 +146,5 @@ if __name__ == '__main__':
|
||||
|
||||
sizes = range(10, 501, 5)
|
||||
analyze_complexity_insert(sizes, presorted=True)
|
||||
analyze_complexity_pop(sizes, presorted=True)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user