模拟题6答案
一、选择题 1 B 2 A 3 B 4 D 5 A 6 C 7 B 8 B 二、填空题 1、O(1) 2、O(n2) 3、Kruskal 4、9 5、(R-F+N)%N 6、4 7、中 8、10
三、判断题 1 × 2 × 3 √ 4 √ 5 × 6 × 7 × 18
6
8 √ 2
四、简答题 1、(1)45 30 26 20 29 12 16 (2)交换的第一对元素为26 15,第一个元素比其他元素都小 2、(1)D B G E F C A (2) AC
F
BEG D 3、(1) A B C D E F
A 0 0 0 0 1 1 B 0 0 0 0 1 0 C 0 0 0 0 0 1 D 1 1 0 0 0 0 E 0 0 1 1 0 0 F 0 0 0 0 0 0 (2)B E C F D A 4、(1)(1*20+2*21+3*22+4*(9-20-21-22))/9=25/9 (2)26 11 4 五、程序填空题 1、(1)top>=100 或者 top==99
5
(2)s->data[s->top] 2、(1)T==NULL 或者 !T
(2)p->rchild!=NULL 或者 p->rchild (3)p 3、-20
六、编程题 1、
void move(int array[],int n) {
int i=0,j=n-1,tmp; while(i < j) {
while(array[i]<=0) i++; while(array[j]>0) j--; if(i< j) {
tmp = array[i];
array[i] = array[j]; array[j] = tmp;
} }
i = 0; j = n-1;
while(i < j) {
while(array[i] != 0)
{
++i;
}
while(array[j] >= 0)
{
--j;
}
if(i < j) {
tmp = array[i];
array[i] = array[j]; array[j] = tmp;
} }
6
} 2、
Node *searchnode(int x,Node *r) {
Node *p;
if(r == NULL) {
p = NULL;
} else {
if(x == r->data)
{
p = r;
}
else if(x != r->lchild->data)
{
p = searchnode(x, r->lchild); }
else if(x != r->rchile->data) {
p = searchnode(x, r->rchild);
} }
return p; }
7

