-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestAVLTree.C
More file actions
executable file
·59 lines (53 loc) · 1.14 KB
/
TestAVLTree.C
File metadata and controls
executable file
·59 lines (53 loc) · 1.14 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
#include <iostream>
#include "BinNodeUtils.H"
using namespace std;
void printAVLPreorder(BinNode<int> * root)
{
if(root==NULL)
{
return;
}
cout<<root->getData()<<"-"<<root->getHeight()<<" ";
printAVLPreorder(root->getL());
printAVLPreorder(root->getR());
}
int main()
{
AVLTree<int> AVL; //declaro un AVL
//probamos el metodo de insertar
cout<<"Insertando"<<endl;
for(int i = 0;i < 10; i++)
{
BinNode<int>* Node = new BinNode<int>(i);
AVL.insert(Node);
}
printAVLPreorder(AVL.getRoot());
cout<<endl;
//verificamos el metodo de buscar
cout<<"Buscando"<<endl;
BinNode<int>* aux = AVL.search(3);
if(aux != NULL)
{
cout<<"El Nodo si se enuentra en el Arbol"<<endl;
}
cout<<"Eliminando"<<endl;
aux = AVL.remove(3);
if(aux != NULL)
{
delete aux;
cout<<"El Nodo si se removio del Arbol"<<endl;
}
cout<<"Recorridos"<<endl;
//preorder(AVL.getRoot()); //recorrido prefijo
preorder(AVL);
cout<<endl;
//inorder(AVL.getRoot()); //recorrido infijo
inorder(AVL);
cout<<endl;
//postorder(AVL.getRoot()); //recorrido postfijo
postorder(AVL);
cout<<endl;
printAVLPreorder(AVL.getRoot());
cout<<endl;
return 0;
}