diff --git a/_04.树/_a.二叉树顺序结构.c b/_04.树/_a.二叉树顺序结构.c index 8ecc8b5..42a15c1 100644 --- a/_04.树/_a.二叉树顺序结构.c +++ b/_04.树/_a.二叉树顺序结构.c @@ -2,7 +2,7 @@ * @Author: Xu Bai * @Date: 2019-07-09 22:50:41 * @LastEditors: Xu Bai - * @LastEditTime: 2019-07-09 23:02:42 + * @LastEditTime: 2019-07-10 22:45:47 */ #include "stdlib.h" #include "stdio.h" @@ -22,7 +22,6 @@ typedef int ElemType; /*0ŵԪ洢ڵ */ typedef ElemType SqBiTree[MAX_TREE_SIZE]; - typedef struct { /*IJ䡢ţ㣩 */ @@ -38,4 +37,43 @@ Status visit(ElemType e) return OK; } +/*ն */ +Status InitBiTree(SqBiTree T) +{ + int i; + for (i = 0; i < MAX_TREE_SIZE; i++) + { + /*ֵΪ */ + T[i] = Nil; + } + return OK; +} + +/*нֵַͻͣ */ +Status CreateBiTree(SqBiTree T) +{ + int i = 0; + printf("밴ֵint0ʾս㣬999ڵ%d\n", MAX_TREE_SIZE); + while (i < 10) + { + T[i] = i + 1; + /*˽㣨գ˫ҲǸڵ*/ + if (i != 0 && T[(i + 1) / 2 - 1] == Nil && T[i] != Nil) + { + printf("˫׵ķǸ%d\n", T[i]); + exit(ERROR); + } + i++; + } + while (i < MAX_TREE_SIZE) + { + /*ոֵTĽ */ + T[i] = Nil; + i++; + } + return OK; +} + +/*˳洢Уȫһ */ +#define ClearBiTree InitBiTree