Question: In a binary tree class, implement a Python method _find(p: _Node, key: int), that takes in a key and a reference to a node p,
In a binary tree class, implement a Python method _find(p: _Node, key: int), that takes in a key and a reference to a node p, where p represents the root of a binary tree, the function should search the binary tree for key, and returns T/F accordingly. What is the time complexity of your function?
class BinaryTree: class _Node: def __init__(self, element, left = None, right = None): self._left = left self._right = right self._element: int = element def __init__(self): self._root = None
def _find(p: _Node, key: int):
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
