Is This a Binary Search Tree?

  • + 1 comment

    What's wrong with this code guys. This is failing 6 test cases

    if root.left or root.right:
            if root.left:
                if root.left.data < root.data:
                    foundl = 1
                else:
                    foundl = 0
            if root.right:
                if root.right.data > root.data:
                    foundr = 1
                else:
                    foundr = 0
            return foundl * foundr * check_binary_search_tree_(root.left) * check_binary_search_tree_(root.right)
        else:
            return 1