Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct node *link;
- typedef struct bst *BST
- struct node {
- int N;
- ITEM item;
- link parent,left,right;
- };
- struct bst {
- int N;
- link head,nodo_fittizio;
- };
- static char buffer[MAXS];
- BST BSTreadPreorder(FILE *file) {
- BST tree;
- tree=crea_BST();
- tree->head=BSTreadPreorderR(file,tree->head);
- return tree;
- }
- link BSTreadPreorderR(FILE *file,link x) {
- int figlio_destro,figlio_sinistro;
- fscanf(file," %s %d %d %d",buffer,numero(x->item),&figlio_destro,&figlio_sinistro);
- inserisci_chiave(x->item,buffer);
- if(figlio_sinistro) {
- x->left=nuovo_nodo(crea_ITEM(),x,NULL,NULL,1);
- x->left=BSTreadPreorderR(file,x->left);
- }
- if(figlio_destro) {
- x->right=nuovo_nodo(crea_ITEM(),x,NULL,NULL,2);
- x->right=BSTreadPreorderR(file,x->right);
- }
- return x;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement