-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBinaryTreeMain.cpp
More file actions
66 lines (64 loc) · 1.3 KB
/
BinaryTreeMain.cpp
File metadata and controls
66 lines (64 loc) · 1.3 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
#include <iostream>
#include<algorithm>
#include <string>
#include <sstream>
#include<vector>
#include<math.h>
#include <iomanip>
#include <map>
#include<set>
#include <fstream>
#include <numeric>
#include <queue>
#include"Tree.h"
using namespace std;
int main()
{
//çàïîëíåíèå áèíàðíîãî äåðåâà
int n, x;
int count = 0;
cout << "n "; cin >> n;
tree* tr = NULL;
cout << endl << "Zapolnite derevo" << endl;
for (int i = 0; i < n; i++)
{
cin >> x;
insert(tr, x);
}
cout << "Kakoy element naiti v dereve? - x: ";
cin >> x;
if (find(tr,x)!=NULL)
{
cout << "X naiden!\n";
}
else
{
cout << "X ne naiden!\n";
}
int mm;
cout << "skolko dobavit? - amount: ";
cin >> mm;
for (int i = 0; i < mm; i++)
{
cout << "Kakoy element dobavit v derevo? - x: ";
cin >> x;
insert(tr, x);
}
cout << "Kakoy element udalit v dereve? - x: ";
cin >> x;
if (find(tr, x) != NULL)
{
remove(tr, find(tr, x)->inf);
cout << "X Udalen!\n";
}
else
{
cout << "X ne naiden!\n";
}
cout << "Vashe derevo vivedeno inorder obhodom" << endl;
inorder(tr); cout << endl;
cout << "Vashe derevo vivedeno preorder obhodom" << endl;
preorder(tr); cout << endl;
cout << "Vashe derevo vivedeno postorder obhodom" << endl;
postorder(tr); cout << endl;
}