diff options
Diffstat (limited to 'source/testbinarytree.py')
-rw-r--r-- | source/testbinarytree.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/source/testbinarytree.py b/source/testbinarytree.py index 7694ad4e..67b19368 100644 --- a/source/testbinarytree.py +++ b/source/testbinarytree.py @@ -22,22 +22,23 @@ print(("{} articles loaded in {} seconds.".format(len(articles), end-begin))) print("Generating the binary tree...") begin = time.time() -tree = binarytree.OrderedBinaryTree() +root = binarytree.Node(articles[0]) +tree = binarytree.OrderedBinaryTree(root) # add the root node (first article of the list) -root = tree.addNode(articles[0]) +#root = tree.addNode(articles[0]) for article in articles[1:]: - tree.insert(root, article) + tree.insert(tree.root, article) end = time.time() print(("Generation done in {0:2f} seconds.".format(end-begin))) print("Maximum depth of the tree:") -print(tree.maxDepth(root)) +print(tree.maxDepth(tree.root)) print("Oldest article:") -oldest_article = tree.minValue(root) +oldest_article = tree.minValue(tree.root) print((oldest_article["article_date"].strftime('%Y-%m-%d %H:%M') + \ " - " + oldest_article["article_title"])) print("Newest article:") -newest_article = tree.maxValue(root) +newest_article = tree.maxValue(tree.root) print((newest_article["article_date"].strftime('%Y-%m-%d %H:%M') + \ " - " + newest_article["article_title"])) -print(tree) +print(tree)
\ No newline at end of file |