aboutsummaryrefslogtreecommitdiff
path: root/source/binarytree.py
diff options
context:
space:
mode:
authorCédric Bonhomme <kimble.mandel@gmail.com>2013-03-18 18:07:07 +0100
committerCédric Bonhomme <kimble.mandel@gmail.com>2013-03-18 18:07:07 +0100
commit20b48cd787961dc8e9ba41ba5fd1e79308ce13cc (patch)
treed5df101cbbc944c99f8a322d315d708485eb366d /source/binarytree.py
parentExperience: test to load all articles in an ordered binary tree. (diff)
downloadnewspipe-20b48cd787961dc8e9ba41ba5fd1e79308ce13cc.tar.gz
newspipe-20b48cd787961dc8e9ba41ba5fd1e79308ce13cc.tar.bz2
newspipe-20b48cd787961dc8e9ba41ba5fd1e79308ce13cc.zip
Ported binary tree implementation to Python 3.
Diffstat (limited to 'source/binarytree.py')
-rw-r--r--source/binarytree.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/source/binarytree.py b/source/binarytree.py
index 48b8ba4e..a83016e0 100644
--- a/source/binarytree.py
+++ b/source/binarytree.py
@@ -88,7 +88,7 @@ class CBOrdTree(object):
pass
else:
self.printTree(root.left)
- print root.data,
+ print(root.data, end=' ')
self.printTree(root.right)
def printRevTree(self, root):
@@ -98,7 +98,7 @@ class CBOrdTree(object):
pass
else:
self.printRevTree(root.right)
- print root.data,
+ print(root.data, end=' ')
self.printRevTree(root.left)
if __name__ == "__main__":
@@ -108,21 +108,21 @@ if __name__ == "__main__":
root = BTree.addNode(0)
# ask the user to insert values
for i in range(0, 5):
- data = int(raw_input("insert the node value nr %d: " % i))
+ data = int(input("insert the node value nr %d: " % i))
# insert values
BTree.insert(root, data)
- print
+ print()
BTree.printTree(root)
- print
+ print()
BTree.printRevTree(root)
- print
- data = int(raw_input("insert a value to find: "))
+ print()
+ data = int(input("insert a value to find: "))
if BTree.lookup(root, data):
- print "found"
+ print("found")
else:
- print "not found"
+ print("not found")
- print BTree.minValue(root)
- print BTree.maxDepth(root)
- print BTree.size(root) \ No newline at end of file
+ print(BTree.minValue(root))
+ print(BTree.maxDepth(root))
+ print(BTree.size(root)) \ No newline at end of file
bgstack15