mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2026-02-02 18:39:09 +08:00
更新图床
This commit is contained in:
@@ -152,7 +152,7 @@ public:
|
||||
|
||||
我来举一个典型的例子如题:
|
||||
|
||||
<img src='https://img-blog.csdnimg.cn/20200920221638903.png' width=600> </img></div>
|
||||
<img src='https://code-thinking-1253855093.file.myqcloud.com/pics/20200920221638903-20230310123444151.png' width=600> </img>
|
||||
|
||||
完全二叉树只有两种情况,情况一:就是满二叉树,情况二:最后一层叶子节点没有满。
|
||||
|
||||
@@ -161,10 +161,10 @@ public:
|
||||
对于情况二,分别递归左孩子,和右孩子,递归到某一深度一定会有左孩子或者右孩子为满二叉树,然后依然可以按照情况1来计算。
|
||||
|
||||
完全二叉树(一)如图:
|
||||

|
||||

|
||||
|
||||
完全二叉树(二)如图:
|
||||

|
||||

|
||||
|
||||
可以看出如果整个树不是满二叉树,就递归其左右孩子,直到遇到满二叉树为止,用公式计算这个子树(满二叉树)的节点数量。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user