2021年3月26日星期五

What is the diameter of a tree that doesn't have at least two leaves?

The diameter of a tree T is the largest of the following quantities:

  1. the diameter of T's left subtree
  2. the diameter of T's right subtree
  3. 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

没有评论:

发表评论