网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

阅读下列函数说明和C函数,将应填入(n)处的字句写在对应栏内。

[说明]

二叉树的二叉链表存储结构描述如下:

lypedef struct BiTNode

{ datatype data;

street BiTNode *lchiht, *rchild; /*左右孩子指针*/ } BiTNode, *BiTree;

下列函数基于上述存储结构,实现了二叉树的几项基本操作:

(1) BiTree Creale(elemtype x, BiTree lbt, BiTree rbt):建立并返回生成一棵以x为根结点的数据域值,以lbt和rbt为左右子树的二叉树;

(2) BiTree InsertL(BiTree bt, elemtype x, BiTree parent):在二叉树bt中结点parent的左子树插入结点数据元素x;

(3) BiTree DeleteL(BiTree bt, BiTree parent):在二叉树bt中删除结点parent的左子树,删除成功时返回根结点指针,否则返回空指针;

(4) frceAll(BiTree p):释放二叉树全体结点空间。

[函数]

BiTree Create(elemtype x, BiTree lbt, BiTree rbt) { BiTree p;

if ((p = (BiTNode *)malloc(sizeof(BiTNode)))= =NULL) return NULL;

p->data=x;

p->lchild=lbt;

p->rchild=rbt;

(1);

}

BiTree InsertL(BiTree bt, elemtype x,BiTree parent)

{ BiTree p;

if (parent= =NULL) return NULL;

if ((p=(BiTNode *)malloc(sizeof(BiTNode)))= =NULL) return NULL;

p->data=x;

p->lchild= (2);

p->rchild= (2);

if(parent->lchild= =NULL) (3);

else{

p->lchild=(4);

parent->lchild=p;

}

return bt;

}

BiTree DeleteL(BiTree bt, BiTree parent)

{ BiTree p;

if (parent= =NULL||parent->lchild= =NULL) return NULL;

p= parent->lchild;

parent->lchild=NULL;

freeAll((5));

return bt;


参考答案

更多 “ 阅读下列函数说明和C函数,将应填入(n)处的字句写在对应栏内。[说明]二叉树的二叉链表存储结构描述如下:lypedef struct BiTNode{ datatype data;street BiTNode *lchiht, *rchild; /*左右孩子指针*/ } BiTNode, *BiTree;下列函数基于上述存储结构,实现了二叉树的几项基本操作:(1) BiTree Creale(elemtype x, BiTree lbt, BiTree rbt):建立并返回生成一棵以x为根结点的数据域值,以lbt和rbt为左右子树的二叉树;(2) BiTree InsertL(BiTree bt, elemtype x, BiTree parent):在二叉树bt中结点parent的左子树插入结点数据元素x;(3) BiTree DeleteL(BiTree bt, BiTree parent):在二叉树bt中删除结点parent的左子树,删除成功时返回根结点指针,否则返回空指针;(4) frceAll(BiTree p):释放二叉树全体结点空间。[函数]BiTree Create(elemtype x, BiTree lbt, BiTree rbt) { BiTree p;if ((p = (BiTNode *)malloc(sizeof(BiTNode)))= =NULL) return NULL;p->data=x;p->lchild=lbt;p->rchild=rbt;(1);}BiTree InsertL(BiTree bt, elemtype x,BiTree parent){ BiTree p;if (parent= =NULL) return NULL;if ((p=(BiTNode *)malloc(sizeof(BiTNode)))= =NULL) return NULL;p->data=x;p->lchild= (2);p->rchild= (2);if(parent->lchild= =NULL) (3);else{p->lchild=(4);parent->lchild=p;}return bt;}BiTree DeleteL(BiTree bt, BiTree parent){ BiTree p;if (parent= =NULL||parent->lchild= =NULL) return NULL;p= parent->lchild;parent->lchild=NULL;freeAll((5));return bt; ” 相关考题
考题 ●试题四阅读下列函数说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】函数QuickSort是在一维数组A[n]上进行快速排序的递归算法。【函数】void QuickSort(int A[],int s,int t){int i=s,j=t+1,temp;int x=A[s];do{do i++;while (1) ;do j--;while(A[j]x);if(ij){temp=A[i]; (2) ; (3) ;}}while(ij);A[a]=A[j];A[j]=x;if(si-1) (4) ;if(j+1t) (5) ;}

考题 阅读以下说明和流程图,将应填入(n)处的字句写在对应栏内。【说明】已知头指针分别为La和lb的有序单链表,其数据元素都是按值非递减排列。现要归并La和Lb得到单链表Lc,使得Lc中的元素按值非递减排列。程序流程图如下所示:

考题 阅读下列函数说明和C代码,将应填入(n)处的字句写在对应栏内。【说明】函数QuickSort是在一维数组A[n]上进行快速排序的递归算法。【函数】void QuickSort( int A[ ],int s,int t){ int i=s,j=t+1,temp;int x=A[s];do{do i ++ ;while (1);do j -- ;while(A[j]>x);if(i<j){temp=A[i];(2);(3);}}while(i<j);A[a] =A[j];A[j] =x;if(s<i-1) (4);if(j+1<t) (5);}

考题 阅读以下说明和C语言函数,将应填入(n)处的字句写在对应栏内。[说明]完成以下中序线索化二叉树的算法。[函数]Typedef int datatype;Typedef struct node {Int ltag, rtag;Datatype data;*lchild,* rchild;}bithptr;bithptr pre;void inthread ( p );{if{inthread ( p->lchild );if ( p->lchild==unll ) (1);if ( P->RCHILD=NULL) p->rtag=1;if (2){if (3) pre->rchild=p;if ( p->1tag==1 )(4);}INTHREAD ( P->RCHILD );(5);}}

考题 阅读下列说明和C函数,将应填入(n)处的字句写在对应栏内。【说明】已知集合A和B的元素分别用不含头结点的单链表存储,函数Difference()用于求解集合A与B的差集,并将结果保存在集合A的单链表中。例如,若集合A={5,10, 20,15,25,30},集合B={5,15,35,25},如图(a)所示,运算完成后的结果如图(b)所示。链表结点的结构类型定义如下:typedef struct Node{ElemType elem;struct Node *next;}NodeType;【C函数】void Difference(NodeType **LA,NodeType *LB){NodeType *pa, *pb, *pre, *q;pre=NULL;(1);while (pa) {pb=LB;while((2))pb=pb->next;if((3)) {if(!pre)*LA=(4);else(5)=pa->next;q = pa;pa=pa->next;free(q);}else {(6);pa=pa->next;}}}

考题 阅读以下说明和C语言函数,将应填入(n)处的语句写在对应栏内。【说明】下面的程序构造一棵以二叉链表为存储结构的二叉树。【函数】BitTree *createbt(BitTree *bt){BitTree *q;struct node *s[30];int j,i;char x;printf("i,x=");scant("%d,%c",i,x);while(i!=0 x!='$'){q=(BitTree *}malloc(sizeof(BitTree));//生成一个结点(1);q->lchild=NULL;q->rchild=NULL;(2) ;if ((3)){j=i/2; // j为i的双亲结点if(i%2==0)(4); //i为j的左孩子else(5); //i为j的右孩子}printf("i,x=");scanf("%d,%c",i,x);}return s[i];}

考题 阅读以下说明和C语言函数,将应填入(n)处的字句写在对应栏内。【说明】下面的程序构造一棵以二叉链表为存储结构的二叉树算法。【函数】BTCHINALR *createbt ( BTCHINALR *bt ){BTCHINALR *q;struct node1 *s [30];int j,i;char x;printf ( "i,x =" ); scanf ( "%d,%c",i,x );while (i!=0 x!='$'){ q = ( BTCHINALR* malloc ( sizeof ( BTCHINALR )); //生成一个结点(1);q->1child = NULL;q->rchild = NULL;(2);if((3);){j=i/2 //j为i的双亲结点if(i%2==0(4) //i为j的左孩子else(5) //i为j的右孩子}printf ( "i,x =" ); scanf ( "%d,%c",i,x ); }return s[1]}

考题 ●试题二阅读下列函数说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】该程序运行后,输出下面的数字金字塔【程序】includestdio.hmain (){char max,next;int i;for(max=′1′;max=′9′;max++){for(i=1;i=20- (1) ;++i)printf(" ");for(next= (2) ;next= (3) ;next++)printf("%c",next);for(next= (4) ;next= (5) ;next--)printf("%c",next);printf("\n");}}

考题 试题三(共 15 分)阅读以下说明和 C 程序,将应填入 (n) 处的字句写在答题纸的对应栏内。

考题 阅读下列说明和?C++代码,将应填入(n)处的字句写在答题纸的对应栏内。 【说明】 阅读下列说明和?Java代码,将应填入?(n)?处的字句写在答题纸的对应栏内。 【说明】 某快餐厅主要制作并出售儿童套餐,一般包括主餐(各类比萨)、饮料和玩具,其餐品种 类可能不同,但其制作过程相同。前台服务员?(Waiter)?调度厨师制作套餐。现采用生成器?(Builder)?模式实现制作过程,得到如图?6-1?所示的类图。