23 lines
581 B
Python
23 lines
581 B
Python
from utils.algo_context import AlgoContext
|
|
from utils.algo_array import Array
|
|
from vorlesung.L05_binaere_baeume.bin_tree import BinaryTree
|
|
|
|
|
|
def analyze_complexity(sizes):
|
|
ctx = AlgoContext()
|
|
for size in sizes:
|
|
z = Array.random(size, -100, 100, ctx)
|
|
tree = BinaryTree(ctx)
|
|
for i in range(size - 1):
|
|
tree.insert(z[i].value)
|
|
ctx.reset()
|
|
tree.insert(z[size - 1].value)
|
|
ctx.save_stats(size)
|
|
|
|
ctx.plot_stats(["comparisons"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sizes = range(1, 1001, 2)
|
|
analyze_complexity(sizes)
|