curriculum/challenges/english/blocks/learn-tree-traversal-by-building-a-binary-search-tree/65c4f2b7178afed8e88f782f.md
If key < node.key evaluates to True, then the new node should be placed in the left subtree.
Delete pass and recursively call the _insert method with left child as the first argument and key as the second argument. Assign the result to the left attribute of the current node.
You should remove the pass keyword from the if block.
({
test: () => {
assert.isFalse(
runPython(
`_Node(_code).find_class("BinarySearchTree").find_function("_insert").find_if("key < node.key").find_bodies()[0].has_pass()`
)
);
},
});
You should call the self._insert method passing node.left and key as the arguments.
({ test: () => assert.match(code, /self\._insert\(\s*node\.left\s*,\s*key\s*\)/) });
You should assign the result of your self._insert() call to the left attribute of the current node.
({ test: () => assert.match(code, /node\.left\s*=\s*self\._insert\(\s*node\.left\s*,\s*key\s*\)/) });
class TreeNode:
def __init__(self, key):
self.key = key
self.left = None
self.right = None
class BinarySearchTree:
def __init__(self):
self.root = None
--fcc-editable-region--
def _insert(self, node, key):
if node is None:
return TreeNode(key)
if key < node.key:
pass
--fcc-editable-region--