<prompt> Given a binary tree, check if it is a binary search tree?  <response>: A binary search tree BST is a binary tree where each node has a value such that:- The value stored in the left subtree of a node must be less than the value of the node.- The value stored in the right subtree of a node must be greater than or equal to the value of the node.- Both left and right subtrees must also be binary search trees.To check if a binary tree is a binary search tree, you can perform an in-order traversal of the tree and store the values in a list. The in-order traversal of a BST produces the values in the sorted order. So if the list is sorted in ascending order, then the binary tree is a BST. Otherwise, it is not.Heres how you can implement the above approach in Python:pythondef isBSTtree: def in_order_traversetree, values: if tree is not None: in_order_traversetree.left, values values.appendtree.val in_order_traversetree.right, values values in_order_traversetree, values return allvaluesi valuesi 1 for i in rangelenvalues - 1Another approach is to recursively check each node with its left and right child. This way you dont need to store the values in a list. Heres how you can implement this in Python:pythondef isBSTtree: def is_bst_helpertree, min_valuefloat-inf, max_valuefloatinf: if tree is None: return True if not min_value tree.val max_value: return False return is_bst_helpertree.left, min_value, tree.val and is_bst_helpertree.right, tree.val, max_value return is_bst_helpertree 