Is This a Binary Search Tree?

  • + 1 comment
    def inorder_list(root):
        values = []
        def inorder_t(root):
            if root is None:
                return
            inorder_t(root.left)
            values.append(root.data)
            inorder_t(root.right)
        inorder_t(root)
        return values
    
    def check_binary_search_tree_(root):
        if root is None:
            return
        values = inorder_list(root)
        if values == sorted(values) and len(values) == len(set(values)):
            return True
        else:
            return False