The diameter of a tree is the length of the longest path between any two nodes. The path can start and end anywhere. Example: In a tree with edges -, -, -, -, the diameter is .
The longest path is (or ). Before reading on, think about this: the longest path either stays entirely in one subtree, or it passes through some node connecting two subtrees. How would you use this?