【发布时间】:2021-09-23 01:38:03
【问题描述】:
Diameter of binary tree is defined as:-
The longest path between 2 leaf nodes in BT.
let left height=lht, right height=rht,
left left diameter=ld , right diameter= rd;
then
diameter= max((lht + rht + 1), max (ld,rd));
但是在斜树中只有一个叶节点,所以我们如何获得斜树的直径。 是0吗?
【问题讨论】:
-
你对直径这个定义的来源是什么?
标签: algorithm data-structures binary-tree