-
Notifications
You must be signed in to change notification settings - Fork 1
/
Prac5_Splitting.cpp
52 lines (34 loc) · 942 Bytes
/
Prac5_Splitting.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
// Write a program to split a balance search tree at
// i. Root
// ii. A given point of split.
#include "AVL.h"
#include <iostream>
int main(){
AVL data("Ajino Motado");
for (int i = 0; i < 10; i++)
{
data.insert(i, i*10);
}
data.PrettyPrinting();
std::pair<AVL*, AVL*> temp = data.splitAtRoot();
temp.first->PrettyPrinting();
temp.second->PrettyPrinting();
delete temp.first;
delete temp.second;
for (int j = 0; j < 10; j++)
{
AVL data2("Carume Satado");
for (int i = 0; i < 10; i++)
{
data2.insert(i, i*10);
}
data2.PrettyPrinting();
std::pair<AVL*, AVL*> temp2 = data2.splitAtKey(j);
std::cout << "Splitting at " << j << std::endl;
temp2.first->PrettyPrinting();
temp2.second->PrettyPrinting();
delete temp2.first;
delete temp2.second;
}
return 0;
}