some small changes

This commit is contained in:
2013-07-08 17:06:52 +02:00
parent 3f7d84c896
commit 79980f3ad9
2 changed files with 3 additions and 3 deletions

View File

@@ -31,7 +31,7 @@ class BinarySearchTree():
node = node.right_child
is_left = False
# we achieved a leaf
# we reached a leaf
node = BinarySearchNode(value, ptr_node)
if is_left:
ptr_node.left_child = node
@@ -40,6 +40,7 @@ class BinarySearchTree():
self.size += 1
class BinarySearchNode():
"""
Defines any node of the Binary Search Tree.
@@ -54,7 +55,7 @@ class BinarySearchNode():
self.right_child = None
def has_left_child(self):
return not(self.left_child is None)
return self.left_child is not None
def has_right_child(self):
return self.right_child is not None

View File

@@ -50,7 +50,6 @@ class test_binary_search_tree(unittest.TestCase):
node = bst.root_node # we have 6
self.assertEqual(node.value, node_val1)
print node.left_child, node.value
self.assertTrue(node.has_left_child())
self.assertEqual(node.left_child.value, node_val2)
self.assertTrue(node.has_right_child())