AMD
一般战友
UID 1943135
精华
1
积分 225
帖子 40
威望 155
K币 85 元
阅读权限 10
注册 2007-1-20
|
|
|
给大家送点计算机考研的资料吧
您所查看的帖子来源于考研加油站考研论坛(bbs.kaoyan.com)
大家好,我是08年考上华科数据库的,我这里有数据结构,操作系统,数据库的期末考试和考研真题的资料,全拍成照片了,300多M,不知道怎么传给大家,上传速度也很慢,且容量受限。我提高的资料里都有我和前辈们做过的答案,可以给大家参考。谁告诉我下好的上传资料的方法。给大家下。希望看此贴的人顶下。
我的QQ329645521 邮箱 62670883@163.com
大家有什么事最好邮箱说,因为我最近做毕业设计,QQ用得少。
我先把我总结的2002-2007的数据结构真题的答案给大家看下吧。
华中科技大学考研数据结构真题答案
-------个人所做的答案
2007
一. 单选题:
1-5:CCABD 6-10: DDAAD 11-15: DDBDA
二.多选题:
16:ABD 17: AD 18: ACD 19: AC 20: BC
五.填空题:
1.L->prior 2..L->next 3.i%2= =0 4.q->prior=p->prior 5.p->next=tail->next 6.p=q
六.算法设计与分析题:
30.
typedef struct bnode
{
char data;
struct bnode *lchild, *rchild;
}bnode,*bitree;
void zuxian (bitree root, char x)
{
bitree p;
stack s;
Initstack(s);
if(root) push(s, root);
while(!stackempty(s))
{
while(gettop(s,p) && p)
{
if(p->data= =x) break;
push(s, p);
}
pop(s,p);
if(!stackempty(s))
{
pop(s,p);
if(p->data= =x) break;
push(s,p->rchild);
}
}
while(!stackempty(s))
{
pop(s,p);
printf(“%c”,p->data);
}
}
或者采用一下算法
void searchzuxian(bitree root, stack &s, elemtype x, int &search)
{
if(root && !search)
{
if(root->data= =x) {search=1; return;}
else
{
push(s,root);
searchzuxian(root->lchild,s,x,search);
searchzuxian(root->rchild,s,x,search);
pop(s,p);
}
}
}
void displayzuxian(bitree root, elemtype x)
{
stack s;
Initstack(s);
int search=0;
searchzuxian(root,s,x,search);
if(stackempty(s)) printf(“No Zuxian”);
else
{
while(stackempty(s))
{
pop(s,p);
printf(p->data);
}
}
}
时间复杂度O(n)
31.
1.
int deletenode(struct mgraph &G,elemtype e)
{
int i,j,flag;
for(flag=0;flag<G.vexnum && e!=G.vexs[flag]; flag++);
if(flag= =G.vexnum && e!=g.vexs[flag]) return 0;
for(i=0;i<G.vexnum;i++)
for(j=flag;j<G.vexnum-1;j++) a[j]=a[j+1];
for(i=flag;i<G.vexnum-1;i++)
for(j=0;j<G.vexnum;j++) a[i[j]=a[i+1][j];
for(i=flag;i<G.vexnum-1;i++) G.vexs= G.vexs[i+1];
G.vexsnum--;
return 1;
}
2.
int deleteedge(struct mgraph &G,elemtype a, G,elemtype b)
{
int ,i,j;
for(i=0; i<G.vexnum && a!=G.vexs;i++);
if(i= = G.vexnum) return 0;
for(j=0;j< G.vexnum && b!=G.vexs[j]; j++);
if(j= = G.vexnum) return 0;
G.arcs[j]=G.arcs[j]=0;
return 1;
}
2006
一、单选题:
1-5: DCBDA 6-10: CADBD 11-15: BBACC 16-18: ACD
二、多选题:
1.AD 2.ABCD 3.BD 4.AD 5.CD 6.AD
五、算法设计和分析题:
1.
void f1(int a[][m] , int n)
{
int i , j;
for(i=1;i<=m;i++)
for(j=I;j<=n;j++)
scanf(“%d”,a[j]);
for(i=1;i<=m-1;i++)
for(j=1;j<=n-1;j++)
{
if(a[j]= =a[j+1] && a[j]= =a[i+1][j] && a[j]= =a[i+1][j+1])
{
printf(“True”);
printf(“%d : (%d,%d);(%d,%d);(%d,%d);(%d,%d)”,a[j],i,j,i,j+1,i+1,j,i+1,j+1);
return;
}
}
printf(“False”);
}
时间复杂度为 O(m*n)
2.
typedef struct bnode
{
int data;
struct bnode *lchild, *rchild;
}bnode, *bitree ;
void preorder1(bitree root, stack &s)
{
if(root)
{
push(s , root);
preorder1(root->lchild,s);
preorder1(root->rchild,s);
}
}
void preorder2(bitree root , stack &s)
{
if(root)
{
pop(s, p);
root->data=p->data ;
preorder2(root->lchild,s);
preorder2(root->rchild,s);
}
}
bitree adjust(bitree root)
{
stack s;
Initstack(s);
preorder1(root,s);
preorder2(root,s);
return root;
}
2005
一. 选择题:
1. AC 2.C 3.CD 4.B 5.AC 6.AD 7.A 8.C
四、
1.
void f1(linklist head , linklist &La , linklist &Lb)
{
p=head->next;
pa=La; pb=Lb;
while(p)
{
if(p->data %2= =0) {pa->next=p;pa=p;}
else {pb->next=p;pb=p;}
p=p->next;
}
pa->next=NULL;
pb->next=NULL;
}
时间复杂度为:O(表长)
2.
#define MAX 100
typdef char SqBitree[MAX];
SqBitree bt;
void inorder(bt t, int root)
{
if(t[root]!=0 && root<=MAX)
{
inorder(t,2*root);
printf(“%c”,t[root]);
inorder(2*root+1);
}
}
时间复杂度为:O(n)
2004
一. 单项选择:
1-5:CDDAA 6-10: CCBCC
二.多选:
1.BD 2.AC 3.ABCD
五.算法设计和分析:
typdef struct lnode
{
char data;
struct lnode *next;
}lnode,*linklist;
void f1()
{
char c;
linklist p.q.r.head;
head=(linklist)malloc(sizeof(lnode));
head->next=NULL;
q=head;
c=getchar();
while(c!=’\n’)
{
p=(linklist)malloc(sizeof(lnode));
p->data=c;
p->next=NULL;
q->next=p;
q=p;
c=getchar();
}//建表
r=head; p=q=head->next;
while(p)
{
while(q->next) {r=q;q=q->next;}
if(p->data!=q->data)
{
printf(“NO”);
p=head;
while(p) {q=p->next; free(p);p=q;}
return;
}
if(p!=q) {free(q); r->next=NULL;}
head->next=p->next;
p=q=head->next;
}
printf(“YES”);
free(head);
}
时间复杂度为: O(n*n)
2003
一. 单选题:
1-5: DBBAD 6-10: CAADB
二.多选题
1.ABD 2.ACD 3.BC
四.算法填空:
(1)pc->next=NULL;
(2) pa=pa->next;
(3) pb=pb->next;
(4) pc=pc->next;
(5) pb= =NULL
(6) pa->next=pb->next;
(7) free(pb)
(8) pa->next;
(9) pa=pa->next;
2002
一. 单选题:
1-5: DABCB 6-10: DAACB 11-12: DB
二.多选题:
1.AC 2.ABC 3.AD 4.CD
三.算法填空:
1.
(1) (node *)malloc(sizeof(node));
(2) (node *)malloc(sizeof(node))
(3) &(p->data)
(4) tail=p
(5) head->next;
(6) p=p->next;
(7) head->next;
(8) f
(9) min=q
(10) q=q->next;
(11) min!=p
(12) p=p->next;
(13) free(f)
(14) free(head)
2.
(15) j++
(16) break
(17) j
(18) x
四.
1.n*(n+1)/2 2.┖ n/2 ┙ 3.O(n*n) 4.s=15,x=4
五.
int count_f(bitree T)
{
if(T)
{
if(T->lchild || T->rchild)
return 1+count_f(T->lchild)+count_f(T->rchild);
}
else return 0;
}
int count_leafs(bitree T)
{
if(T)
{
if(T->lchild || T->rchild)
return count_leafs(T->lchild)+count_leafs(T->rchild);
else return 1;
}
}
转载请注明出自bbs.kaoyan.com,本贴地址:http://bbs.kaoyan.com/viewthread.php?tid=2210466
附件: 您所在的用户组无法下载或查看附件
※ 来源:考研论坛 bbs.kaoyan.com
|
|