from utils.memory_manager import MemoryManager from utils.memory_array import MemoryArray from utils.literal import Literal from vorlesung.L05_binaere_baeume.avl_tree import AVLTree def analyze_complexity(sizes): """ Analysiert die Komplexität :param sizes: Eine Liste von Eingabegrößen für die Analyse. """ for size in sizes: MemoryManager.purge() # Speicher zurücksetzen tree = AVLTree() random_array = MemoryArray.create_random_array(size, -100, 100) for i in range(size-1): tree.insert(int(random_array[Literal(i)])) MemoryManager.reset() tree.insert(int(random_array[Literal(size-1)])) MemoryManager.save_stats(size) MemoryManager.plot_stats(["cells", "compares"]) if __name__ == "__main__": sizes = range(1, 1001, 2) analyze_complexity(sizes)