#! /usr/bin/python3 # ================================================================== # test tree avg_height method # ================================================================== ##import btree_9 as bt import btree_a as bt def fill_tree(tree,values): for i in values: tree.insert(bt.Node(i)) values = [ [],[30],[30,20],[30,20,10], [30,20,10,5],[30,20,10,5,1], [30,20,10,5,1,40,50,55,59] ] for a in values: tree = bt.BinaryTree() ##tree.set_debug(True) fill_tree(tree,a) ##print('--------------------------------------------------') ##tree.print_tree_structure() ##print('--------------------------------------------------') avg = tree.avg_height() print('-----------------------------------------') print(a) print('avg = {:.2f}'.format(avg))