Print each tree node's level and whether it is balanced
Given a tree, walk it with a depth-first search and report, for every node, its level and whether the subtree under it is balanced (by the definition the interviewer gives, such as child heights or subtree sums differing by at most a limit). The statement is long, so pin down the input format and the exact balance rule first, compute what you need bottom-up in one pass, and test your own code.
No answer yet. Write the first one; the best answer gets endorsed.
