-
Notifications
You must be signed in to change notification settings - Fork 0
/
treeA.h
58 lines (39 loc) · 943 Bytes
/
treeA.h
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
#ifndef treeA_h
#define treeA_h
struct avl_node {
char *username;
char *password;
struct avl_node *right;
struct avl_node *left;
};
typedef struct avl_node node;
struct avl_tree {
struct avl_node *root;
};
typedef struct avl_tree tree;
//Limpa a estrutura
void cleanTree(node* root);
//Cria base de AVL
tree* createTree();
//Cria temp nodes
node* createNode();
//Altura da arvore
int heightTree(node* node);
//Calcula Balanceamento
int balanceFactor(node* node);
//4 funcoes de rotacao
node* rotateLL(node* node);
node* rotateLR(node* node);
node* rotateRL(node* node);
node* rotateRR(node* node);
//Balancea consoante nodo
node* balanceNode(node* node);
//Balancea AVL
void balanceTree(tree* root);
//Insere na arvore
void insertTree(tree* root, char *name, char *pass);
//Print da arvore
void printTree(node* root, FILE *fd);
//1- Existe User, 0- Nao existe!
int existUser(node* root, char *name, char *pass);
#endif