It is helpful to look into common and terminal cases:
common case: height of node is maximum of heights of left and right childrens + 1;
▓ ← Root height
▓ ← Right child height
▓
Left child height → ▓ ▓
▓ ▓
▓ ▓ |
Terminal case: height of nonexisting node is -1, therefore height of node without children is 0.
So you just ask your childrens about their heights, children asks another childrens and so on until you reach leaf node and then recursion is going back: children report to their parents, parents add 1 to highest number and report to their parents etc.
Towe of hanoi is simple too:
terminal case: to move one disc, we just move it. That is all.
common case: we move all discs but the larger one to the extra rod, move largest disc on target rod, move remaining discs on target rod. Function is going to delegate further and further moving of smaller stacks until it asks to move a single disc (terminal case) then will unwind back: 2 disc stack is able to complete, its completition helps 3disc stack, etc.
It is similar to mathematical induction: there you too formulates common case, prove that terminal case is true and by domino principle common case is true too.