diff options
author | Cédric Bonhomme <kimble.mandel@gmail.com> | 2013-03-23 21:05:20 +0100 |
---|---|---|
committer | Cédric Bonhomme <kimble.mandel@gmail.com> | 2013-03-23 21:05:20 +0100 |
commit | 538ad691be38618ae39bd5093b8608ea34f08684 (patch) | |
tree | 526adf2dae581222784548e1dbe307a113e2503f /source/testbinarytree.py | |
parent | Bugfix: wrong function call in the recursive tree walking function. (diff) | |
download | newspipe-538ad691be38618ae39bd5093b8608ea34f08684.tar.gz newspipe-538ad691be38618ae39bd5093b8608ea34f08684.tar.bz2 newspipe-538ad691be38618ae39bd5093b8608ea34f08684.zip |
Improvement to the binarytree implementation: the root is now given to the __init__ function.
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 |