Read the entire context:
The children's subtrees each have size at most 2n/3 - the worst case occurs when the last row of the tree is exactly half full
Since the running time T(n)
is analysed by the number of elements in the tree (n
), and the recursion steps into one of the subtrees, we need to find an upper bound on the number of nodes in a subtree, relative to n
, and that will yield that T(n) = T(max num. nodes in subtree) + O(1)
The worst case of number of nodes in a subtree is when the final row is as full as possible on one side, and as empty as possible on the other. This is called half full. And the left subtree size will be bounded by 2n/3
.
If you're proposing a case with only a few nodes, then that's irrelevant, since all base cases can be considered O(1)
and ignored.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…