学习网考试学习资料

Gzu521.com

北师大教育技术系数据结构复习题(2)

考研专业课   点击:次   发布时间:2006-8-12   【字体: 】   来源:Gzu521.com
Gzu521.com我的学习网
( PP [=(NT2B(k!| 3 [ 本 资 料 来 源 于 贵 州 学 习 网 考研一方考研专业课 http://Www.gzU521.com ] ( PP [=(NT2B(k!| 3

六.下面一段程序输出什么?
void main(void)
{ stack s; queue q; pqueue pq; char ch;
  char  sentence[]=”stackqueue”;
for(int i=0;i<strlen(sentence);i++) 
     pq.pqinsert(sentence[i]);
while(!pq.pqempty())
{ ch = pq.pqdelete();
  while(!s.stackempty())
   { ch = s.pop(); cout<<ch;  }
  cout<<endl;
   while(!q.qempty())
    {  ch = q.qdelete();cout<<ch;  }
  cout<<endl;  }
 if ( isupper(ch) s.push(ch);
  else  q.qinsert(ch);   }
 
七.(1)用preorder遍历一棵binary search tree得到序列 20 15 10 17 16 18 25 22 21 24 35给出这棵树,并给出postorder遍历.
(2) 说明函数f的作用
 void inorderassign(treenode<int>*t,array<int>& a,int& i)
{
if(t!=null)
{
inoderassign(t->right(),a,i);
 a[i++]=t->data;
 inorderassign(t->left();a,i);
}
}
void f(array<int>& a)
{
binstree<int> tree;
for(int i=0;i<a.listsize();i++)
   tree.insert(a[i]);
i=0;
inorderassign(tree.getroot(),a,i);
}
八. 说明函数pat的功能
int pat(char str[],int i)
{ int m=strlen(str)/2;
  if(i>=m)return 1;
  else if (str[i] !=str[m+i])return 0;
       else return pat(str,i+1); }
字符串a 取
  (a)“powwow”  (b) “sees”  (c) “123123” 
  (d) “123321” 
分别给出 函数pat(a,0)的值.

上 一 页 下 一 页
3页: 第 [1] [2] [3]

责任编辑:gzu521

考研一方分类
考研信息
考研复习
考研英语
考研数学
考研政治
考研专业课
MBA/EMBA/MPA
同等学历/在职硕士
法律硕士
会计硕士
工程硕士
教育硕士
分类推荐信息
更多...
大类最新文章
更多...