using namespace std; #include #include "tree.h" #include "persona.h" // FUNZIONI AUSILIARIE static void print_spaces(int depth) { for(int i=0;iitem = v; t->left = NULL; t->right = NULL; res = OK; } } else if (confronta(chiaveDi(v),t->item)<=0) res = insert(t->left, v); else if (confronta(chiaveDi(v),t->item) > 0) res = insert(t->right, v); return res; } tree cerca (const tree & t,chiave c) { tree res; if (emptyp(t)) res = NULL; else if (confronta(c,t->item)==0) res = t; else if (confronta(c,t->item)<0) res = cerca(t->left,c); else if (confronta(c,t->item)>0) res = cerca(t->right,c); return res; } void print_ordered(const tree & t) { if (!emptyp(t)) { print_ordered(t->left); stampa(t->item); print_ordered(t->right); } } void print_indented(const tree & t) { static int depth=0; depth++; if (!emptyp(t)) { print_indented(t->right); print_spaces(depth); stampa(t->item); print_indented(t->left); } depth--; }