class DSATreeNode:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
class DSABinarySearchTree:
def __init__(self):
self.root = None
def insert(self, data):
if self.root is None:
self.root = DSATreeNode(data)
else:
self._insert(data, self.root)
This line of code is located in one python file
import searchtree
bst = DSABinarySearchTree()
# Test insertion
bst.insert(5)
bst.insert(3)
bst.insert(8)
bst.insert(2)
bst.insert(4)
bst.insert(7)
bst.insert(9)
This line of code is in a different python file. "searchtree" is the name of the first python file where the "class DSABinarySearchTree" is located. Note that the python program needs to run on the terminal