-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo_client_1.cpp
More file actions
114 lines (85 loc) · 3.86 KB
/
demo_client_1.cpp
File metadata and controls
114 lines (85 loc) · 3.86 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "demo_final_1.cpp"
// #include "test2_m.cpp"
#include <iostream>
#include <string>
using namespace std;
int main()
{
// Insert Node
// Delete Node
// Delete Treap
// Copy Treap
// Display
cout<<"\n--------------------------------------------------------------------------------------------------------------------------------\n\n";
Treap_t<int> t_1;
t_1.insert(19);
t_1.insert(23);
t_1.insert(5);
t_1.insert(1);
t_1.insert(90);
t_1.insert(28);
t_1.insert(55);
// for(int i = 0; i<30; i++)
// {
// t_1.insert(rand()%100);
// }
cout<<"Tree T_1:\n\n"<<t_1<<"\n";
cout<<"\n--------------------------------------------------------------------------------------------------------------------------------\n\n";
Treap_t<double> t_2;
t_2.insert(1.5);
t_2.insert(83.972);
t_2.insert(5.0);
t_2.insert(12.28);
t_2.insert(59.08);
t_2.insert(3.14);
t_2.insert(99.99);
cout<<"Tree T_2:\n\n"<<t_2<<"\n";
cout<<"\n--------------------------------------------------------------------------------------------------------------------------------\n\n";
Treap_t<string> t_3;
t_3.insert("D");
t_3.insert("B");
t_3.insert("G");
t_3.insert("A");
t_3.insert("P");
t_3.insert("Q");
t_3.insert("T");
cout<<"Tree T_3:\n\n"<<t_3<<"\n";
cout<<"\n--------------------------------------------------------------------------------------------------------------------------------\n\n";
cout << "Deleting G and T from t_3\n\n";
t_3.delete_("G");
t_3.delete_("T");
cout<<"Tree T_3:\n\n"<<t_3<<"\n";
cout<<"\n--------------------------------------------------------------------------------------------------------------------------------\n\n";
vector<int> v_1 = {9, 82, 158, 1912, 174, 242, 99, 108, 235, 911, 100, 102, 555};
//build constructor - O(n)
Treap_t<int> t_4(v_1.begin(), v_1.end());
cout << "Using generic build constructor to construct T_4\n\n";
cout<<"Tree T_4:\n\n"<<t_4<<"\n";
cout<<"\n--------------------------------------------------------------------------------------------------------------------------------\n\n";
//copy ctor call
Treap_t<int> t_5(t_1);
cout << "Using Copy constructor to copy from T_1\n\n";
cout<<"Tree T_5:\n\n"<<t_5<<"\n";
cout<<"\n--------------------------------------------------------------------------------------------------------------------------------\n\n";
//copy constructor for double
Treap_t<double> t_6 = t_2;
cout << "Using Copy constructor to copy from T_2\n\n";
cout<<"Tree T_6:\n\n"<<t_6<<"\n";
cout<<"\n--------------------------------------------------------------------------------------------------------------------------------\n\n";
//copy assignment operator for string
Treap_t<string> t_7;
t_7 = t_3;
cout << "Using Copy assignment operator to copy from T_3\n\n";
cout<<"Tree T_7:\n\n"<<t_7<<"\n";
cout<<"\n--------------------------------------------------------------------------------------------------------------------------------\n\n";
cout << "Using Copy assignment operator to copy from T_1 where T_4 was not initially empty\n\n";
cout<<"Assigning t_4 to t_1\n\n";
t_1 = t_4;
cout<<"Tree T_1:\n\n"<<t_1<<"\n";
cout<<"\n--------------------------------------------------------------------------------------------------------------------------------\n\n";
cout<<"Tree T_4:\n\n"<<t_4<<"\n";
cout<<"\n--------------------------------------------------------------------------------------------------------------------------------\n\n";
// Treap_t<int> t_5 = {1,2,3,4,5};
// cout<<"Tree T_5:\n\n"<<t_5<<"\n";
// cout<<"\n--------------------------------------------------------------------------------------------------------------------------------\n\n";
}