-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
47 lines (46 loc) · 1.27 KB
/
main.cpp
File metadata and controls
47 lines (46 loc) · 1.27 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
// Code by Cevat Sonmez Yucel
#include "AVLNode.h"
#include "AVLTree.h"
#include <string>
#include <iostream>
int main() {
AVLTree myTree;
// Interface for using the AVL Tree
while(true) {
std::cout << "Insert: i <integer>\n";
std::cout << "Remove: r <integer> \n";
std::cout << "Exists: e <integer>\n";
std::cout << "Print: p\n";
std::cout << "Stop: s\n";
std::cout << "------------\n";
std::string command;
int value;
std::cin >> command;
if (command == "s") {
std::cout << "------------\n";
break;
}
if (command == "p") {
myTree.printTree();
continue;
}
std::cin >> value;
if (command == "i") {
myTree.insert(value);
}
if (command == "r") {
myTree.remove(value);
}
if (command == "e") {
std::cout << "------------\n";
if (myTree.exists(value)) {
std::cout << "'" << value << "'" << " exists in the tree\n";
}
else {
std::cout << "'" << value << "'" << " does not exist in the tree\n";
}
std::cout << "------------\n";
}
}
return 0;
}