-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path树
More file actions
71 lines (70 loc) · 1.48 KB
/
树
File metadata and controls
71 lines (70 loc) · 1.48 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//二叉排序树-----------------------------------------------------------------------------------------------
//#include<cstdio>
//#include<iostream>
//
//using namespace std;
//
//int HashTable[1010]={0};
//
////构造函数的直接赋值,不用在手动赋值
//struct TNode{
// int data;
// struct TNode *left,*right;
// TNode(int x):data(x),left(NULL),right(NULL){}
//};
//
////注意函数返回类型,左右节点的赋值
//TNode *InsertCreation(TNode *T,int val){
// if(!T)
// T=new TNode(val);
// else if(val<T->data)
// T->left=InsertCreation(T->left, val);
// else
// T->right=InsertCreation(T->right, val);
// return T;
//}
//
//void PostOrder(TNode *T){
// if(T){
// PostOrder(T->left);
// PostOrder(T->right);
// printf("%d ",T->data);
// }
//}
//
//void InOrder(TNode *T){
// if(T){
// InOrder(T->left);
// printf("%d ",T->data);
// InOrder(T->right);
// }
//}
//
//void PreOrder(TNode *T){
// if(T){
// printf("%d ",T->data);
// PreOrder(T->left);
// PreOrder(T->right);
// }
//}
//
//int main(){
// TNode *T(NULL);
// int n,x;
// scanf("%d",&n);
//
// for(int i=0;i<n;i++){
//
// scanf("%d",&x);
// if(!HashTable[x])
// T=InsertCreation(T,x);
// //二叉排序树的创建一定要返回树的节点
// HashTable[x]++;
// }
//
// PreOrder(T);
// printf("\n");
// InOrder(T);
// printf("\n");
// PostOrder(T);
//}