- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitial.cpp
More file actions
Latest commit
151 lines (110 loc) · 4.19 KB
/
Copy pathinitial.cpp
File metadata and controls
151 lines (110 loc) · 4.19 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#include"initial.h"
//////////////////////////////////////////////////////////////////
//**************************************************************//
// AVL TREE //
//**************************************************************//
//////////////////////////////////////////////////////////////////
AVL_depth::AVL_depth() {
depth_AVL_accumulator = 0.0;
avgDepth_AVL = 0;
counter_AVL = 0;
}
voidAVL_depth::initial_AVL(int nodes, int trees) {
int nodeCounter = nodes;
int treeCounter = trees;
while (treeCounter > 0) {
AVL_Tree tree = *new AVL_Tree;
nodeCounter = nodes;
while (nodeCounter > 0) {
srand(time(NULL));
int randomNum = rand() % 1000;
tree.insert(randomNum);
nodeCounter--;
}
depth_AVL_accumulator += tree.getHeight();
counter_AVL++;
treeCounter--;
}
}
floatAVL_depth::get_AVL_avgDepth() {
return (avgDepth_AVL = (float)depth_AVL_accumulator / counter_AVL);
}
intAVL_depth::get_depth_AVL_accumulator() {
return depth_AVL_accumulator;
}
//////////////////////////////////////////////////////////////////
//**************************************************************//
//**************************************************************//
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//**************************************************************//
// BINARY SEARCH TREE //
//**************************************************************//
//////////////////////////////////////////////////////////////////
binS_depth::binS_depth() {
avgDepth_binS = 0.0;
depth_binS_accumulator = 0;
counter_binS = 0;
}
voidbinS_depth::initial_binS(int nodes, int trees) {
int nodeCounter = nodes;
int treeCounter = trees;
while (treeCounter > 0) {
BinS_Tree tree;
nodeCounter = nodes;
while (nodeCounter > 0) {
int randomNum = rand() % 1000;
tree.initilize(randomNum);
nodeCounter--;
}
depth_binS_accumulator += tree.maxDepth();
counter_binS++;
treeCounter--;
}
}
floatbinS_depth::get_binS_avgDepth() {
return (avgDepth_binS = depth_binS_accumulator / counter_binS);
}
intbinS_depth::get_depth_binS_accumulator() {
return depth_binS_accumulator;
}
//////////////////////////////////////////////////////////////////
//**************************************************************//
//**************************************************************//
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//**************************************************************//
// BINARY TREE //
//**************************************************************//
//////////////////////////////////////////////////////////////////
binT_depth::binT_depth() {
avgDepth_binT = 0.0;
depth_binT_accumulator = 0;
counter_binT = 0;
}
voidbinT_depth::initial_binT(int nodes, int trees) {
int nodeCounter = nodes;
int treeCounter = trees;
while (treeCounter > 0) {
binTree tree;
nodeCounter = nodes;
while (nodeCounter > 0) {
int randomNum = rand() % 1000;
tree.insert(randomNum);
nodeCounter--;
}
depth_binT_accumulator += tree.maxDepth();
counter_binT++;
treeCounter--;
}
}
floatbinT_depth::get_binT_avgDepth() {
return (avgDepth_binT = (float)depth_binT_accumulator / counter_binT);
}
intbinT_depth::get_depth_binT_accumulator() {
return depth_binT_accumulator;
}
//////////////////////////////////////////////////////////////////
//**************************************************************//
//**************************************************************//
//////////////////////////////////////////////////////////////////