-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
executable file
·63 lines (48 loc) · 1.29 KB
/
main.cpp
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
// Sample driver
// EE 312 Fall 2018
//
// The BST should work for any data type or object.
// Other user created objects must have the << operator overloaded for
// output.
//
#include <iostream>
#include <fstream>
#include "BST312.h"
using namespace std;
template <typename T>
void print(vector<T> vec){
for(int i = 0 ; i < vec.size() ; i++){
cout << vec[i] << endl;;
}
}
int main() {
ifstream inFile;
inFile.open("test.txt");
BST_312<string> bst;
string s;
inFile >> s;
while (inFile) {;
cout << "inserting ... " << s << endl;
bst.insertItem(s);
inFile >> s;
}
cout << "postorder traversal is " << endl;
print(bst.postOrderTraversal());
cout << endl;
cout << "preorder traversal is " << endl;
print(bst.preOrderTraversal());
cout << endl;
cout << "inorder traversal is " << endl;
print(bst.inOrderTraversal());
cout << endl;
cout << "Remove items " << endl;
cout << "number of nodes in tree before delete is " << bst.countNodes() << endl;
print(bst.postOrderTraversal());
cout << endl;
bst.makeEmpty();
cout << "number of nodes in tree after delete is " << bst.countNodes() << endl;
cout << endl;
if(bst.isItemInTree("This")){
cout << "YES";
}
}