/****头文件"head.h"**********/
#include<stdio.h>
#include<math.h>
struct BiT {
char data;
BiT *lchild, *rchild;
};
struct Queue {
BiT *P;
Queue *next;
};
struct LinkQueue {
Queue *front; //队头指针
Queue *rear; //队尾指针
};
/**************函数体*********/
BiT* CreateBiTree(int n) {
//构造二叉链表表示的二叉树T
int i, m = pow(2,n)-1;
BiT *c = new BiT[m];
for(i = 0; i < m; i++) {
c[i].data = 'A' + i;
c[i].lchild = &c[2*i+1];
c[i].rchild = &c[2*i+2];
}
for(i = pow(2,n-1)-1; i < m; i++)
c[i].lchild = c[i].rchild = NULL;
return c;
}
void PreOrderTraverse(BiT *T) {
// 先序遍历二叉树T
if (T) {
printf("%c",T->data);
PreOrderTraverse(T->lchild);
PreOrderTraverse(T->rchild);
}
}