-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
111 lines (96 loc) · 2.4 KB
/
Copy pathmain.cpp
File metadata and controls
111 lines (96 loc) · 2.4 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
#include <iostream>
#include "Model/RedBlackTree.h"
#include "ModelGestor/BPlusTreeController.h"
#include "Model/BTree.h"
#include "ModelGestor/AVLTreeController.h"
#include "UI/menu.h"
void InsertBPlus(BPlusTreeController* tree, int value) {
cout << "INSERT " << value << endl;
tree->Insert(value);
tree->Print();
cout << endl << endl;
}
void BPlusTest() {
BPlusTreeController* tree = new BPlusTreeController(4);
InsertBPlus(tree, 15);
InsertBPlus(tree, 16);
InsertBPlus(tree, 17);
InsertBPlus(tree, 18);
InsertBPlus(tree, 19);
InsertBPlus(tree, 20);
InsertBPlus(tree, 30);
InsertBPlus(tree, 40);
InsertBPlus(tree, 50);
InsertBPlus(tree, 60);
InsertBPlus(tree, 70);
InsertBPlus(tree, 80);
InsertBPlus(tree, 90);
InsertBPlus(tree, 100);
cout << endl << "Remove 30" << endl << endl;
tree->Remove(30);
tree->Print();
cout << endl << "Remove 15" << endl << endl;
tree->Remove(15);
tree->Print();
cout << endl << "Remove 20" << endl << endl;
tree->Remove(20);
tree->Print();
}
void AVLTest() {
AVLTreeController* avlTree = new AVLTreeController();
avlTree->AddBalanced(1);
avlTree->AddBalanced(2);
avlTree->AddBalanced(3);
avlTree->AddBalanced(4);
avlTree->AddBalanced(5);
avlTree->AddBalanced(6);
avlTree->AddBalanced(7);
avlTree->AddBalanced(8);
avlTree->AddBalanced(9);
avlTree->AddBalanced(10);
avlTree->Print();
cout << "REMOVE 4" << endl;
avlTree->Delete(4);
cout << "" << endl << endl;
avlTree->Print();
cout << "REMOVE 2" << endl;
avlTree->Delete(2);
cout << "" << endl << endl;
avlTree->Print();
cout << "REMOVE 9" << endl;
avlTree->Delete(9);
cout << "" << endl << endl;
avlTree->Print();
}
void RedBlackTest() {
RedBlackTree *bst = new RedBlackTree();
bst->insert(55);
bst->insert(40);
bst->insert(65);
bst->insert(60);
bst->insert(75);
bst->insert(57);
bst->printTree();
bst->deleteNode(60);
bst->printTree();
}
void BTreeTest(){
BTree *b = new BTree(3);
b->insert(20);
b->insert(18);
b->insert(8);
b->insert(9);
b->insert(10);
b->insert(11);
b->insert(15);
b->insert(16);
b->insert(17);
cout << "The B-tree is: ";
b->deletion(20);
b->traverse();
}
int main() {
Menu *menu = new Menu();
menu->menuPrincipal();
return 0;
}