1class BST:
2 def insert(self, root, val):
3 if root is None:
4 return TreeNode(val)
5 if val <= root.val:
6 root.right = self.insert(root.right, val)
7 else:
8 root.left = self.insert(root.left, val)
9 return root
no lines flagged
#010PracticeMedium20 min · 120 XP
BST Insert Breaks Ordering
This BST insert function places nodes on the wrong side of the root for equal values, breaking in-order traversal.
Flagged linesNo lines flagged yet
What's wrong?
Flag a line or write a note to submit.