mirror of
https://github.com/jlengrand/Coding4Interviews.git
synced 2026-03-10 08:11:24 +00:00
some small changes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user