-
Notifications
You must be signed in to change notification settings - Fork 0
/
SqBiTree_Test.c
56 lines (47 loc) · 1.19 KB
/
SqBiTree_Test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* =====================================================================================
*
* Filename: SqBiTree_Test.c
*
* Description:
*
* Version: 1.0
* Created: 12/02/2014 09:35:56 PM
* Revision: none
* Compiler: gcc
*
* Author: 张世龙 (mn), [email protected]
* Company: free
*
* =====================================================================================
*/
#include "Public.h"
#include "SqBiTree.h"
int main()
{
SqBiTree tree;
InitTree(tree);
CreateTree(tree);
PreOrderTraverse(tree);
printf("depth:%d\n",TreeDepth(tree));
ElemType rootData;
Root(tree,&rootData);
printf("Root:%d\n",rootData);
Position pos;
pos.level = 3;
pos.order = 2;
printf("Value(3,2):%d\n",Value(tree,pos));
ElemType tmpData = 37;
pos.level = 5;
pos.order = 1;
Assign(tree,pos,tmpData);
PreOrderTraverse(tree);
printf("depth:%d\n",TreeDepth(tree));
printf("parent:%d\n",Parent(tree,37));
printf("leftChild:%d\n",LeftChild(tree,8));
printf("leftChild:%d\n",RightChild(tree,8));
printf("LeftSibling:%d\n",LeftSibling(tree,9));
printf("LeftSibling:%d\n",RightSibling(tree,8));
LevelOrderTraverse(tree);
return 0;
}