From 538ad691be38618ae39bd5093b8608ea34f08684 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sat, 23 Mar 2013 21:05:20 +0100 Subject: Improvement to the binarytree implementation: the root is now given to the __init__ function. --- source/binarytree.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source/binarytree.py') diff --git a/source/binarytree.py b/source/binarytree.py index 52e32db7..c9747d57 100644 --- a/source/binarytree.py +++ b/source/binarytree.py @@ -21,11 +21,11 @@ class OrderedBinaryTree(object): """ Represents a binary ordered . """ - def __init__(self): + def __init__(self, root): """ Initializes the root member. """ - self.root = None + self.root = root def addNode(self, data): """ @@ -147,7 +147,8 @@ class OrderedBinaryTree(object): """ Pretty display. """ - return ", ".join([article["article_title"] for article in self.in_order_traversal(self.root)]) + return ", ".join([article["article_title"] for article in \ + self.in_order_traversal(self.root)]) if __name__ == "__main__": # Point of entry in execution mode. -- cgit