#define KEYVALUE "%g"
typedef double tipo_chiave;

struct tnodo{
	tipo_chiave key;
	struct tnodo *maggiori; /* chiavi piu' grandi */
	struct tnodo *minori; /* chiavi piu' piccole */
};

/* tree.c */
struct tnodo *crea_albero(void);
struct tnodo *crea_nodo(void);
void inorder_r(struct tnodo *p);
void preorder_r(struct tnodo *p);
void postorder_r(struct tnodo *p);
struct tnodo *tree_copy(struct tnodo *p);
int tree_match(struct tnodo *t1, struct tnodo *t2);
struct tnodo *tree_search(struct tnodo *p, tipo_chiave v);
struct tnodo *tree_search_i(struct tnodo *p, tipo_chiave v);
struct tnodo *tree_search_ins(struct tnodo *p, tipo_chiave v);
struct tnodo *tree_insert(struct tnodo *tree, struct tnodo *n);
int tree_height(struct tnodo *p);
void destroy_tree(struct tnodo *p);
struct tnodo *rotR(struct tnodo *h);
struct tnodo *rotL(struct tnodo *h);
struct tnodo *root_tree_insert(struct tnodo *tree, struct tnodo *n);
struct tnodo *root_tree_insert_w(struct tnodo *tree, struct tnodo *n);
struct tnodo *rand_tree_insert(struct tnodo *tree, struct tnodo *n);
int tree_size(struct tnodo *tree);
struct tnodo *tree_select(struct tnodo *p, int index);
struct tnodo *tree_partition(struct tnodo *p, int k);
struct tnodo *tree_join_delete(struct tnodo *a, struct tnodo *b);
struct tnodo *tree_delete(struct tnodo *p, tipo_chiave v);
struct tnodo *tree_balance(struct tnodo *p);