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?
https://stackoverflow.com/questions/66827790/what-is-the-diameter-of-a-tree-that-doesnt-have-at-least-two-leaves March 27, 2021 at 11:39AM
没有评论:
发表评论