<prompt> Write an algorithm to implement a binary search tree.  <response>: 1. Define a Node class that will represent a node in the tree, with properties left, right and value to store children and the nodes value, respectively.pythonclass Node: def __init__self, data: self.left None self.right None self.value data2. Define a BinarySearchTree class that will contain the root node of the tree, and methods for inserting a node, searching for a node, and traversing the tree.pythonclass BinarySearchTree: def __init__self: self.root None3. Implement the insert method by starting from the root node, and iterate down the tree by comparing the new value to the current node and moving left if the new value is smaller or right if the new value is larger until an empty spot is found. Then, insert the new node in the empty spot.python def insertself, data: new_node Nodedata if self.root is None: self.root new_node return current_node self.root while current_node: if data current_node.value: if current_node.left is None: current_node.left new_node return else: current_node current_node.left else: if current_node.right is None: current_node.right new_node return else: current_node current_node.right4. Implement the search method that takes a value as input and returns True if the value is in the tree, and False otherwise. Similar to the insert method, the method starts from the root node and iterates down the tree by comparing the search value to the current node and moving left or right until the value is found or the end of the tree is reached.python def searchself, data: current_node self.root while current_node: if data current_node.value: return True elif data current_node.value: current_node current_node.left else: current_node current_node.right return False5. Implement the traversal methods, such as inorder, preorder, and postorder, which visit nodes in a specific order. 