forked from wsldevv/Binary-Tree-Base
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
36 lines (25 loc) · 671 Bytes
/
main.cpp
File metadata and controls
36 lines (25 loc) · 671 Bytes
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
#include <iostream>
#include "tree_lib.h"
using namespace std;
// DO NOT EDIT LEAF VALUE
// E.G. t->get_leaf(10)->value = x;
// ^ DON'T DO THAT
int main() {
// initialize a new binary search tree
Tree *t = new Tree(50);
// makes 100 leafs
for (int i=0; i<100;i++) {
t->add_leaf(new Leaf(i));
}
// editing node data example
t->get_leaf(10)->data = "Hello, World!";
cout << t->get_leaf(10)->data << "\n";
// delete leaf example
t->delete_leaf(10);
// re-creates leaf
t->add_leaf(new Leaf(10));
t->get_leaf(10)->data = "Hello again, World!";
cout << t->get_leaf(10)->data << "\n";
// delete the tree from memory
t->del();
};