由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - interview quiz
相关主题
请大牛看道题高盛 - core Infrastructure Strat 1-hour-quiz
问个算time complexity的问题on-site谈得还不错,可是 quiz特别差
计算几何面试分析化学phD面试都问什么啊
什么时候可以开始刷题求教:有面过Apple Touch hardware engineer的么?请教下24小时内做完quiz问题
请问如何binary search出数组中的重复元素求 apple multi touch 组 skype interview经验
问个G家面试题请问online quiz
A classic Java Quiz河床的面试过程,请教
上星期三Garmin电面至今无消息,估计没希望了大家有人听过 American institutes for research 这个机构吗?
相关话题的讨论汇总
话题: function话题: intarray话题: int话题: give话题: arraysum
进入JobHunting版参与讨论
1 (共1页)
a********r
发帖数: 218
1
For questions 1-4, assume that an array stores integers and has a maximum
size of 100. The array is used to store two distinct data structures, BOTH
a queue and a stack. The answer should be written in C or C++ and should
not use any existing data structure libraries.
1.Write a function that pushes an integer into the stack.
2.Write a function that pops an integer from the stack.
3.Write a function that enqueues an integer into the queue.
4.Write a function that dequeues an integer from the queue.
5.For the given C function, below, please answer the 3 questions below:
int Function()
{
int intArray[N];
int arraySum = 0;
for (int i = 0;i< N;i++)
{
intArray[i] = i;
For(int J = 1;j {
intArray[i] = J * intArray[
i]
}
}
For(int k = 0;k {
arraySum += intArray[k];
}
return arraySum;
}
a)Give the O(n) runtime complexity for the function.
b)Give an optimized version (if one exists) for the function.
c) Give the O(n) runtime complexity for the optimized version.
l*********8
发帖数: 4642
2
1-4说是要在一个数组上同时实现stack和queue吧?

BOTH

【在 a********r 的大作中提到】
: For questions 1-4, assume that an array stores integers and has a maximum
: size of 100. The array is used to store two distinct data structures, BOTH
: a queue and a stack. The answer should be written in C or C++ and should
: not use any existing data structure libraries.
: 1.Write a function that pushes an integer into the stack.
: 2.Write a function that pops an integer from the stack.
: 3.Write a function that enqueues an integer into the queue.
: 4.Write a function that dequeues an integer from the queue.
: 5.For the given C function, below, please answer the 3 questions below:
: int Function()

l*********8
发帖数: 4642
3
5. 原来程序O(N^2)
改成O(N),
int Function(int N)
{
int Factorial=1;
for (int j=1; j Factorial *= j;
return N*(N-1)/2 * Factorial ;
}
小心溢出
1 (共1页)
进入JobHunting版参与讨论
相关主题
大家有人听过 American institutes for research 这个机构吗?请问如何binary search出数组中的重复元素
面试的项目不给钱怎么办问个G家面试题
关于C++中const的问题A classic Java Quiz
读phd的同学不要找在国外的中国本科女生上星期三Garmin电面至今无消息,估计没希望了
请大牛看道题高盛 - core Infrastructure Strat 1-hour-quiz
问个算time complexity的问题on-site谈得还不错,可是 quiz特别差
计算几何面试分析化学phD面试都问什么啊
什么时候可以开始刷题求教:有面过Apple Touch hardware engineer的么?请教下24小时内做完quiz问题
相关话题的讨论汇总
话题: function话题: intarray话题: int话题: give话题: arraysum