问题 问答题

【说明】 下面的程序构造一棵以二叉链表为存储结构的二叉树。 【函数】 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]; }

答案

参考答案:

解析:(1)q->data=x (2)s[i]=q (3)i!=1
(4)s[j]->lchild=q (5)s[j]->rchild=q

[分析]:
本题考查二叉树的构造。
题目要求构造一棵二叉树,而二叉树的性质如下:如果对一棵有n个结点的完全二叉树的结点按层序编号(从第1层到第[log2n]+1层,每层从左到右),则对任一结点i(1≤i≤n),有:
(1)如果i=1,则结点i无双亲,是二叉树的根;如果i>1,则其双亲是结点[i/2]。
(2)如果2i>n,则结点i为叶子结点,无左孩子:否则,其左孩子是结点2i。
(3)如果2i+1>n,则结点i无右孩子;否则,其右孩子是结点2i+1。
下面我们来看程序。程序中声明了一个结点指针数组,用来保存生成的树中结点。用从键盘输入的方式来确定要插入的字符x和此结点在二叉树中的位置i(这个位置是指在完全二叉树中编号的位置)。
第(1)空是在生成一个新结点后的操作,生成了一个新结点后,自然要将从键盘输入的字符x值存放进来,以及修改结点的两个指针域。程序中指针域都赋了空,因此,第(1)空的任务应该是将字符x写进来,因此,此空答案为q->data=x。
第(2)空是在对结点完成操作后的操作,根据题目意思,生成的结点应该要保存到数组s中,此数组是一个指针数组,保存结点时,是将结点的地址保存进数组中相应的位置,因此,此空答案为s[il=q。
第(3)空是条件判断语句的条件,结合下面的程序可以知道,此条件语句用来判断当前结点是不是根结点,如果不是,才执行条件语句中的内容。根据上面的分析,如果i=1,则结点i无双亲,是二叉树的根,因此,此空的答案为i!=1。
第(4)空处后面有注释,说明i是j的左孩子结点,这个时候我们应该让j结点的左孩子指针指向结点i,此空就是要实现这一功能。而结点,j被存放在数组s中的第j个位置,因此,此空答案为s[i]->lchild=q。
从程序中很容易看出,第(5)空与第(4)空功能相似,只是说i是j的右孩子结点,因此,让j结点的右孩子指针指向结点乙此空答案为s[j]->rchild=q。

完形填空
Recently, I have begun to do rides with a group of guys who ride professionally (老练地). The first day, I finished the ride with great   36 , though I tried hard to keep up with one guy for most the ways. To my   37 , I did a little better the second time.
I decided to work harder to   38 . Yesterday, I   39  so much on my ride that I missed the short route (路线) I usually take;   40 , I stayed on the long route. I had never used this route, so I wasn’t really sure about which   41  I should take. Thankfully, a group of four riders   42 , and I just followed them.
A few minutes later, one of the guys got a flat tire (爆了的轮胎), and, with the help of the others, he had it   43  in about a minute. We all waited there   44  he changed his tire. After we started riding again, I noticed something   45 . The guy at the front would ride   46  for a couple of minutes, then he would move over to the side,   47  his way to the end of the line, and the guy behind him would move into the lead position. The process (过程) would   48  every few minutes. This was a lot easier than riding alone, trying to   49  the first rider. This time I had a great time – and I think it is the   50  I’ve ever gone.
This made me realize how important teamwork is, and the   51  of having a great team. The point is that you don’t have to be at your best   52 . You give it your all for a while, and then you let the guy   53  you do the same. The entire team improves because you don’t have to be the   54  all the time. You get your time to shine, and so does everyone else. You cannot get anywhere – or even make any worthwhile improvement – without a   55 . Who else will stop and help you to change your flat tire?
小题1:
A.comfortB.carefulnessC.difficultyD.bravery
小题2:
A.delightB.disappointmentC.surpriseD.amazement
小题3:
A.adjustB.improveC.approveD.increase
小题4:
A.turnedB.checkedC.carriedD.focused
小题5:
A.thereforeB.otherwiseC.insteadD.still
小题6:
A.endB.directionC.routeD.place
小题7:
A.developedB.formedC.leftD.appeared
小题8:
A.usedB.workedC.changedD.stopped
小题9:
A.ifB.sinceC.whileD.before
小题10:
A.naturalB.unusualC.simpleD.regretful
小题11:
A.suddenlyB.quicklyC.immediatelyD.finally
小题12:
A.makingB.leadingC.gettingD.keeping
小题13:
A.showB.passC.continueD.repeat
小题14:
A.catch up withB.end up withC.put up withD.come up with
小题15:
A.longestB.highestC.biggestD.fastest
小题16:
A.planB.aimC.valueD.effort
小题17:
A.at a timeB.at the timeC.for some timeD.all the time
小题18:
A.beforeB.betweenC.behindD.above
小题19:
A.heroB.speakerC.juniorD.organizer
小题20:
A.friendB.teamC.practiceD.rid
单项选择题