I’m stuck finding the path of the given node so I can find the right side but not the left side. For example, when I search for 5 in X=”+ * + 5 7 4 1 6″, the output is like [‘+’, ‘*’, ‘+’, ‘5’] but when I try to search for any number on the lift subtree, it gives
Tag: binary-search-tree
Why are the base cases for my BST not running when searching for a target node?
I am solving a Binary search tree problem where we are given a target node, and want to return the node with value that’s closest to this target in the BST. Here is my code: It is retuning ‘None’ for many of the test cases. But running through the code on paper, it should be working. It is because the
TypeError while executing Binary tree code
I am getting an error while testing the following function. Can anybody help me with this? code: Here’s the test script: And here’s the error I am getting: Please let me know why is this happening? Answer As your largest_leaf_value will return None in its recursion base case, you need to be ready for lres or rres to get None