题目略
教材:林碧英版数据结构
第五章算法设计题1、2、4、5、6、7、10
1.
typedef struct BiTNode { ElemType data; struct BiTNode *lchild,*rchild; }BiTNode,*BiTree; int DepthT(BiTree T) { int x=0,y=0; if(T==NULL) return 0; x=DepthT(T->lchild); y=DepthT(T->rchild); return x>y ? x+1:y+1; } int Depth_x(BiTree &T,ElemType x) { int m=0,n=0; if(T==NULL) return 0; if(T->data==x) return DepthT(T); m=Depth_x(T->lchild,x); n=Depth_x(T->rchild,x); return m>n ? m:n; }2.
typedef struct BiTNode { ElemType data; struct BiTNode *lchild,*rchild; }BiTNode,*BiTree; bool IsComplete(BiTree T) { SqQueue Q; InitQueue(Q); if(!T) return 1; EnQueue(Q,T); while(!IsEmpty(Q)) { DeQueue(Q,p); if(p) { EnQueue(Q,p->lchild); EnQueue(Q,p->rchild); } else while(!IsEmpty(Q)) { DeQue