From 0dc784dbf5a8d012f97b90ccc4a2b596e65b77f3 Mon Sep 17 00:00:00 2001 From: Xu Bai <1373953675@qq.com> Date: Wed, 10 Jul 2019 23:12:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 3 ++- _04.树/_a.二叉树顺序结构.c | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 87d69fa..8f09319 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,7 @@ { "python.pythonPath": "C:\\ProgramData\\anaconda\\python.exe", "files.associations": { - "cstdio": "c" + "cstdio": "c", + "stdlib.h": "c" } } \ No newline at end of file diff --git a/_04.树/_a.二叉树顺序结构.c b/_04.树/_a.二叉树顺序结构.c index 42a15c1..459397b 100644 --- a/_04.树/_a.二叉树顺序结构.c +++ b/_04.树/_a.二叉树顺序结构.c @@ -2,11 +2,12 @@ * @Author: Xu Bai * @Date: 2019-07-09 22:50:41 * @LastEditors: Xu Bai - * @LastEditTime: 2019-07-10 22:45:47 + * @LastEditTime: 2019-07-10 23:12:44 */ #include "stdlib.h" #include "stdio.h" #include "io.h" +#include "math.h" #define OK 1 #define ERROR 0 @@ -77,3 +78,35 @@ Status CreateBiTree(SqBiTree T) /*˳洢Уȫһ */ #define ClearBiTree InitBiTree +Status BiTreeEmpty(SqBiTree T) +{ + if (T[0] == Nil) + { + return TRUE; + } + else + { + return FALSE; + } +} + +int BiTreeDepth(SqBiTree T) +{ + int i, j = -1; + for (i = MAX_TREE_SIZE - 1; i >= 0; i--) + { + /*ҵһ */ + if (T[i] != Nil) + { + break; + } + } + i++; + do + { + j++; + } while (i >= powl(2, j)); + /*2j */ + return j; +} +