Added avl height benchmark

This commit is contained in:
2025-05-06 19:02:00 +02:00
parent e45091b066
commit 93311c4ad5
12 changed files with 328 additions and 94 deletions
+14 -3
View File
@@ -1,9 +1,9 @@
import matplotlib.pyplot as plt
def plot(header:str, first:list[int], second:list[int], log=False):
def plot(header:str, first:list[int], second:list[int], log=False, labels=("Lista", "Drzewo BST")):
plt.figure(figsize=(10, 6))
plt.plot(range(1000,25001,1000), first, label="Lista")
plt.plot(range(1000,25001,1000), second, label="Drzewo BST")
plt.plot(range(1000,25001,1000), first, label=labels[0])
plt.plot(range(1000,25001,1000), second, label=labels[1])
plt.xlabel("Rozmiar tablicy")
plt.ylabel("Czas (ms)")
if log:
@@ -45,3 +45,14 @@ if __name__ == "__main__":
plot("Tworzenie", listTimes['build'], bstTimes['build'])
plot("Wyszukiwanie", listTimes['search'], bstTimes['search'], log=True)
plot("Usuwanie", listTimes['delete'], bstTimes['delete'])
with open("avl.csv", "r") as file:
data = file.read()
lines = data.split('\n')
headers = lines[0].split(',')
values = [line.split(',') for line in lines[1:-1]]
bstHeights = [int(x[0]) for x in values]
avlHeights = [int(x[1]) for x in values]
plot("AVl", bstHeights, avlHeights, log=True, labels=("Drzewo BST", "Drzewo AVL"))