-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
70 lines (60 loc) · 1.7 KB
/
main.cpp
File metadata and controls
70 lines (60 loc) · 1.7 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
//
// main.cpp
// test
//
// Created by Shulin on 2018/5/6.
// Copyright © 2018年 Shulin. All rights reserved.
//
#include <iostream>
#include <vector>
#include "tree.hpp"
#include "narraytree.hpp"
using namespace std;
int main(void)
{
node *root = new node(10);
insert(root, 6);
insert(root, 27);
insert(root, 18);
insert(root, 4);
insert(root, 9);
insert(root, 33);
// std::cout << "Pre order: " << std::endl;
// preordertree(root);
// std::cout <<std::endl;
// std::cout << "Recursion Pre order: " << std::endl;
// iterpreordertree(root);
// std::cout << "Morris Pre order: " << std::endl;
// morrispreorder(root);
// std::cout << "Post order: " << std::endl;
// postordertree(root);
// std::cout <<std::endl;
// std::cout << "Recurdion Post order: " << std::endl;
// iterpostordertree(root);
// std::cout << "In order: " << std::endl;
// inordertree(root);
// std::cout <<std::endl;
// std::cout << "Recursion In order: " << std::endl;
// iterinordertree(root);
// std::cout << "Morris In order: " << std::endl;
// morrisinorder(root);
// std::cout << "Level first: " << std::endl;
// breathfirst(root);
node* t1 = new node(2);
insert(t1,1);
insert(t1,4);
insert(t1,5);
node* t2 = new node(3);
insert(t2,1);
insert(t2,6);
insert(t2,7);
insert(t2,2);
std::cout << "tree 1 :" << std::endl;
preordertree(t1);
std::cout << "tree 2 :" << std::endl;
preordertree(t2);
std::cout <<"Merge two trees: " << std::endl;
preordertree(itermergeTrees(t1,t2));
std::cout << "max depth: " << maxDepthRecursive(t1) << std::endl;
return 0;
}