forked from sheisc/COMP9024
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
52 lines (36 loc) · 1.43 KB
/
main.c
File metadata and controls
52 lines (36 loc) · 1.43 KB
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
#include <stdio.h>
#include <stdlib.h>
#include "BiTree.h"
void PrintNodeInfo(BiTreeNodePtr pNode) {
printf("Visiting %s\n", pNode->value.name);
pNode->visited = 1;
}
int main(int argc, char **argv, char **env) {
// Create a binary tree
BiTreeNodePtr root = CreateBinaryTree();
// create a sub-directory 'images' (if it is not present) in the current directory
system("mkdir -p images");
// remove the *.dot and *.png files in the directory 'images'
//system("rm -f images/*.dot images/*.png");
//GenOneImage(root, "OurBiTree", "images/OurBiTree", 0);
printf("***************** PreOrderTraversal() **********************\n");
PreOrderTraversal(root, PrintNodeInfo);
printf("\n\n");
printf("***************** InOrderTraversal() **********************\n");
InOrderTraversal(root, PrintNodeInfo);
printf("\n\n");
printf("***************** PostOrderTraversal() **********************\n");
PostOrderTraversal(root, PrintNodeInfo);
printf("\n\n");
printf("***************** PreOrderTraversal2() **********************\n");
ResetNodeState(root);
PreOrderTraversal2(root, PrintNodeInfo);
printf("\n\n");
printf("***************** PostOrderTraversal2() **********************\n");
ResetNodeState(root);
PostOrderTraversal2(root, PrintNodeInfo);
printf("\n\n");
// Free the heap memory
ReleaseBinaryTree(root);
return 0;
}