Write an algorithm that determines if a binary tree is balanced or not. A balanced binary tree is defined as one where for every node, its left and right subtrees differ in height by no more than 1.
Sigiloso
temp = [] def check (root, temp): if not root: return if root.l_child != None: if root.data < root.l_child.data: temp.append(False) if root.r_child != None: if root.data < root.l_child.data: temp.append(False) check(root.l_child, temp) check(root.r_child, temp) temp.append(True) return temp c = check(r, temp) if all(c): print "Balanced" else: print "Not Balanced"