[s:37]
#define NULL 0
#define N 9
typedef struct node {int date;
struct node *lchild, *rchild;
} NODE;
NODE *t; int a[ ]={7,2,3,6,13,10,8,5,9};
函数调用形式为t=create(a,0,n-1)
NODE *create(int a[],int low, int up)
{int m; NODE*tree;
if(low>up)return(NULL);
else
{m=(low+up)/2;
tree=(NODE *)malloc(sizeof(NODE));
tree->date=a[m];
tree->lchild=create(a,low,m-1);
tree->rchild=create(a,m+1,up);
printf("%3d",tree->date);
return(tree);
}
}
输出____
画出树T的结构图____
#define NULL 0
#define N 9
typedef struct node {int date;
struct node *lchild, *rchild;
} NODE;
NODE *t; int a[ ]={7,2,3,6,13,10,8,5,9};
函数调用形式为t=create(a,0,n-1)
NODE *create(int a[],int low, int up)
{int m; NODE*tree;
if(low>up)return(NULL);
else
{m=(low+up)/2;
tree=(NODE *)malloc(sizeof(NODE));
tree->date=a[m];
tree->lchild=create(a,low,m-1);
tree->rchild=create(a,m+1,up);
printf("%3d",tree->date);
return(tree);
}
}
输出____
画出树T的结构图____