Analyze the worst-case time and space complexities of the breadth-first algorithm for checking whether a given tree is balanced you were asked to design in Exercise 4.7. Compare them with the complexities of a straightforward depth-first algorithm for the same problem, which uses the algorithm for tree isomorphism that you were asked to design in Exercise 4.6 as a subroutine applied to the offspring of every node containing a binary operation.
Design an algorithm that checks whether an expression is balanced, given its tree representation. (Hint: perform breadth-first traversal of the tree.)
Design an algorithm that checks whether two expressions are isomorphic, given their tree representation.