The diameter of a tree T is the largest of the following quantities:
- the diameter of T's left subtree
- the diameter of T's right subtree
- the longest path between leaves that goes through the root of T (this can be computed from the heights of the subtrees of T)
Source: https://www2.cs.duke.edu/courses/spring00/cps100/assign/trees/diameter.html
However, it doesn't say what is the diameter of tree that doesn't have at least two leaves, like a root-only tree, or 1 -> 2? Is it 0, undefined, infinity or negative infinity?
See Question&Answers more detail:os