|
发表于 2016-7-9 12:26:00
|
显示全部楼层
一、选择题
1.C 2.D 3.D 4.B 5.C
6.A 7.B 8.A 9.C 10.A
二、填空题
1. 1. O(n2),O(nlog2n)
2. 2. p>llink->rlink=p->rlink; p->rlink->llink=p->rlink
3. 3. 3
4. 4. 2k-1
5. 5. n/2
6. 6. 50,51
7. 7. m-1,(R-F+M)%M
8. 8. n+1-i,n-i
9. 9. (19,18,16,20,30,22)
10. 10. (16,18,19,20,32,22)
11. 11. A[j]=1
12. 12. 等于
13. 13. BDCA
14. 14. hashtable=0,hashtable[k]=s
三、算法设计题
1. 1. 设单链表中有仅三类字符的数据元素(大写字母、数字和其它字符),要求利用原单链表中结点空间设计出三个单链表的算法,使每个单链表只包含同类字符。
typedef char datatype;
typedef struct node {datatype data; struct node *next;}lklist;
void split(lklist *head,lklist *&ha,lklist *&hb,lklist *&hc)
{
lklist *p; ha=0,hb=0,hc=0;
for(p=head;p!=0;p=head)
{
head=p->next; p->next=0;
if (p->data>='A' && p->datanext=ha; ha=p;}
else if (p->data>='0' && p->datanext=hb; hb=p;} else {p->next=hc; hc=p;}
}
}
2. 2. 设计在链式存储结构上交换二叉树中所有结点左右子树的算法。
typedef struct node {int data; struct node *lchild,*rchild;} bitree;
void swapbitree(bitree *bt)
{
bitree *p;
if(bt==0) return;
swapbitree(bt->lchild); swapbitree(bt->rchild);
p=bt->lchild; bt->lchild=bt->rchild; bt->rchild=p;
}
3. 3. 在链式存储结构上建立一棵二叉排序树。
#define n 10
typedef struct node{int key; struct node *lchild,*rchild;}bitree;
void bstinsert(bitree *&bt,int key)
{
if (bt==0){bt=(bitree *)malloc(sizeof(bitree)); bt->key=key;bt->lchild=bt->rchild=0;}
else if (bt->key>key) bstinsert(bt->lchild,key); else bstinsert(bt->rchild,key);
}
void createbsttree(bitree *&bt)
{
int i;
for(i=1;i
}
以上就是为大家整理的计算机数据结构测试题及参考答案,希望能够帮助大家更好的备考,祝大家能够取得好成绩!
点击查看跨考教育2015年考研大纲解析 |
|