校园招聘面试题

  • 格式:doc
  • 大小:24.50 KB
  • 文档页数:2

1、 简答题。 请说出树的深度优先、广度优先遍历算法,及非递归实现的特点。
2、 找错
struct complex_t
{
int real;
int imag;
}
int create(complex_t*p,unsigned int n)
{
p=new complex_t[n];
if(p==NULL){
return -1;
}
return 0;
}
int compute()
{
//implement
complex_t*comps;
unsigned int num=0;
cin>>num;
if(create(comps,num)=0){
cerr<<”create comps failes!”<
return n-1;
}
long long int sum=0;
unsigned int pos=0;
cin>>pos;
while(pos<
cin>>comps[pos].real>>comps[pos].imag;
sum+=comps[pos].real*comps[pos+1].real+comps[pos].imag*comps[pos+1].imag;
pos+=2;
}
cout<<”sum is”<
return 0;
}
第二部分 程序与算法
1、 一个典型的大型项目,通常由众多组件构成,这些组件之间复杂的编译依赖于在构建整
个系统时,是最让人头疼的地方之一。现在就有这样的一个大型项目,由N(N>1000)个
组件构成,每个组件都是可以编译的,但组件之间存在着编译依赖,如组件N1依赖N2,
即编译N1时N2必须已经先编译完成,否则N1不能完成编译,但组件之间没有循环依赖
的问题。请设计一种快速算法,能完成整个项目的编译构建过程,并给出算法的时间复杂度。

2、 实现一个函数的完整代码。
int maxContinuNum(const char*inputstr.char*outputstr)
功能:
在以‘\0’结尾的字符串中找出连续最长的数字串,并把这个串的长度返回,并把这个最长
数字串付给其中一个函数参数outputstr所指内存。不能用strlen之类的库函数。