Question: This code is for python and it needs to be modified so the implementation of the binary search tree can handle duplicate keys properly. This
This code is for python and it needs to be modified so the implementation of the binary search tree can handle duplicate keys properly. This implies, if a key already exists in the tree, then the new payload should replace the old value. Thanks
Do not add another node with the same key. Determine where the new functionality needs to be added. Show the printout of your results along with the code.
Part 1 of the code.

Part 2 of the code.

1 class BinarySearchTree: def init (self): self.root-None self.size 0 def length (self) return self.size def len (self): return self.size 12 defiter (self): return self.oot iter_) def put (self keyval): if self.root: 17 self._put (key,valself.root) else: self.root TreeNode (key.val) = self.size-self.size +1 def -put (selfkey.Val.currentNode) if key
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
