-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbtree.h
More file actions
50 lines (35 loc) · 1.39 KB
/
btree.h
File metadata and controls
50 lines (35 loc) · 1.39 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
#ifndef BTREE_H
#define BTREE_H
/*Declaracao incompleta para a estrutura de lista*/
struct node;
/*estrutura que representa um nó da arvore*/
struct b_node
{
void *data;
struct b_node *left_son;
struct b_node *right_son;
};
/*cria novo no*/
struct b_node *new_b_node (void *data);
/*acidiona o nó "nd", à arvore apontada por bthree*/
void add_b_node (struct b_node **btree, struct b_node *nd, int (*compare) (struct b_node *, struct b_node *));
/*Retorna 3 para ambos, 2 para filho direito, 1 para esquerdo, 0 para nenhum e -1 p/ erro*/
int sons_of (struct b_node *father);
/*
* gera as rotas para as folhas
* retorna uma lista de rotas (listas)
*/
struct node *trace_leaf_routes (struct b_node *btree);
/*retorna uma lista com os dados da arvore em preorder e posorder*/
void in_order_lst (struct b_node *tree, struct node **list);
void reverse_order_lst (struct b_node *tree, struct node **list);
/*apaga a arvore*/
void destroy_tree (struct b_node **tree);
/*função que balanceia a arvore, segundo o criterio apresentado "menor"- lado esquerdo, "maior"- lado direito*/
void balance_tree (struct b_node **tree);
/*retorna a profundidade do nível da arvore. retorna 0 se a arvore esta vazia*/
int get_level (struct b_node *tree);
/*verifica se a arvore é uma arvore de busca*/
int is_search_tree (struct b_node *tree, int (*compare) (struct b_node *, struct b_node *));
/*get level*/
#endif