I need help with the theory on calculating the height of a binary tree, typically the notation.
I have read the following article:
Calculating height of a binary tree
And one of the posts gives the following notation:
height(node) = max(height(node.L), height(node.R)) + 1
Let's assume I have the following binary tree:
10
/ \
5 30
/ \ / \
4 8 28 42
Do I therefore calculate the max value on the left node (8) and the max node on the right (42) and then add 1? I don't quite understand how this notation works in order to calculate the height of the tree.