Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5548ff8

Browse files
🐱(tree): 110. 平衡二叉树
补充复杂度说明
1 parent ece29c7 commit 5548ff8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎docs/data-structure/tree/recursion/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ class Solution:
400400
return max(left_depth, right_depth)
401401
```
402402

403-
- 时间复杂度:$O(nlogn)$。最差情况需要遍历树的所有节点,判断每个节点的最大高度又需要遍历该节点的所有子节点。详见[题解中的复杂度分析](https://leetcode-cn.com/problems/balanced-binary-tree/solution/ping-heng-er-cha-shu-by-leetcode/)
403+
- 时间复杂度:$O(nlogn)$。最差情况需要遍历树的所有节点,判断每个节点的最大高度又需要遍历该节点的所有子节点。如果树是倾斜的,则会到达 $O(n^2)$ 复杂度。详见[题解中的复杂度分析](https://leetcode-cn.com/problems/balanced-binary-tree/solution/ping-heng-er-cha-shu-by-leetcode/)
404404
- 空间复杂度:$O(n)$。如果树完全倾斜(退化成链),递归栈将包含所有节点。
405405

406406
### 解二:自底向上

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /