Careercup - Microsoft面试题 - 5173689888800768
2014-05-11 05:21
原题:
Complexity of a function:
int func_fibonacci ( int n) {
if (n < ) {
return n;
} else {
return ( func_fibonacci(n-) + func_fibonacci(n-));
}
}
题目:求上面函数的复杂度。
解法:时间复杂度就是斐波那契数,空间也是。
代码:
// http://www.careercup.com/question?id=5173689888800768
/*
T(0) = 1;
T(1) = 1;
T(n) = T(n - 1) + T(n - 2);
Thus T(n) is exactly nth Fibonacci number.
T(n) = (((1 + sqrt(5)) / 2) ^ n - ((1 - sqrt(5)) / 2) ^ n) / sqrt(5);
*/
int fibonacci (int n)
{
if (n < ) {
return n;
} else {
return fibonacci(n - ) + fibonacci(n - );
}
} int main()
{
return ;
}
Careercup - Microsoft面试题 - 5173689888800768的更多相关文章
- Careercup - Microsoft面试题 - 6314866323226624
2014-05-11 05:29 题目链接 原题: Design remote controller for me. 题目:设计一个遥控器. 解法:遥控什么?什么遥控?传统的红外线信号吗?我只能随便说 ...
- Careercup - Microsoft面试题 - 6366101810184192
2014-05-10 22:30 题目链接 原题: Design database locks to allow r/w concurrency and data consistency. 题目:设计 ...
- Careercup - Microsoft面试题 - 24308662
2014-05-12 07:31 题目链接 原题: I have heard this question many times in microsoft interviews. Given two a ...
- Careercup - Microsoft面试题 - 5700293077499904
2014-05-12 00:02 题目链接 原题: For a given map (ie Bing map) given longitude/latitude/ how would you desi ...
- Careercup - Microsoft面试题 - 5204967652589568
2014-05-11 23:57 题目链接 原题: identical balls. one ball measurements ........ dead easy. 题目:9个看起来一样的球,其中 ...
- Careercup - Microsoft面试题 - 5175246478901248
2014-05-11 23:52 题目链接 原题: design an alarm clock for a deaf person. 题目:为聋人设计闹钟? 解法:聋人听不见,那么闪光.震动都可行.睡 ...
- Careercup - Microsoft面试题 - 5718181884723200
2014-05-11 05:55 题目链接 原题: difference between thread and process. 题目:请描述进程和线程的区别. 解法:操作系统理论题.标准答案在恐龙书 ...
- Careercup - Microsoft面试题 - 6282862240202752
2014-05-11 03:56 题目链接 原题: Given an integer array. Perform circular right shift by n. Give the best s ...
- Careercup - Microsoft面试题 - 5428361417457664
2014-05-11 03:37 题目链接 原题: You have three jars filled with candies. One jar is filled with banana can ...
随机推荐
- 替换 PDF 文字
1.从http://pan.baidu.com/s/1pJlVBqN下载Foxit Phantom.exe: 2.安装这个软件: ① 弹出这个对话框时选择“运行”: ② 授权协议选择“同意”: ③ 选 ...
- android从资源文件中读取文件流显示
在android中,假如有的文本文件,比如TXT放在raw下,要直接读取出来,放到屏幕中显示,可以这样:代码区: private void doRaw(){ InputStream is = this ...
- State
#include <iostream> using namespace std; #define DESTROY_POINTER(ptr) if (ptr) { delete ptr; p ...
- [leetcode]_Climbing Stairs
我敢保证这道题是在今早蹲厕所的时候突然冒出的解法.第一次接触DP题,我好伟大啊啊啊~ 题目:一个N阶的梯子,一次能够走1步或者2步,问有多少种走法. 解法:原始DP问题. 思路: 1.if N == ...
- silverlight 退出当前页面、跳转到主页面
1.退出当前页面 private void imgExit_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (Message ...
- jquery中each()函数
今天在使用each函数时,发现写的js代码明明木有问题,为什么点击没有执行呢.js始终处于入门阶段,只好瞎鼓捣. 弄了半天,总算可以了.代码如下: <script type="text ...
- 【php学习之路】字符串操作
无论学习那种语言,字符串操作都是必备的基础.学php的时候总是会不知不觉的与C#比较,用起来总觉得怪怪的没有那么顺手,有些命名也差别很大,再加上很多函数命名是简写形式不百度下还真不知道什 ...
- jquery ajax跨域请求详解
本文章来给大家详细jquery中的ajax跨域请求, 在JQuery对于Ajax的跨域请求有两类解决方案,不过都是只支持get方式.分别是JQuery的jquery.ajax jsonp格式和jque ...
- 一,U盘安装 CentOS 6.5 minimal
U盘安装盘: CentOS-6.5的版本有四个,分别是: 1.CentOS-6.5-i386-netinstall.iso 通过网络安装的,需要联网 2.CentOS-6.5-i386-minimal ...
- 电商、商城类APP常用标签"hot"--第三方开源--LabelView
LabelView是在github上一个开源的标签库.其项目主页是:https://github.com/linger1216//labelview LabelView为一个TextView,Imag ...