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 ...
随机推荐
- c++强制类型转换(static_cast,const_cast,dynamic_cast,reinterpret_cast)
static_cast <typeid>(exdlvssion) static_cast 很像 C 语言中的旧式类型转换.它能进行基础类型之间的转换,也能将带有可被单参调用的构造函数或用户 ...
- jQuery中$(function() {});问题详解
$(function() {});是$(document).ready(function(){ })的简写,最早接触的时候也说$(document).ready(function(){ })这个函数是 ...
- jquery 获取元素坐标
不错哦! 原文地址:http://jianzhong5137.blog.163.com/blog/static/9829049201182295833503/ 绝对X,Y坐标,可以用offset()方 ...
- linux网络bond技术
http://blog.chinaunix.net/uid-20799583-id-3117665.html1.创建bond0配置文件vi /etc/sysconfig/network-scripts ...
- WinForm程序安装、发布流程
一 签名 所谓签名就是给应用程序一个身份,申请一个专利.签名的时候需要选择证书.就向我们上学一样,得奖了老师给你发个证书.如果不进行签名,杀毒软件会把你打包后的exe文件作为病毒处理. 签名的步骤: ...
- MVC5 Identity 用用户名登录而不用电子邮件
1.修改AccountViewModels ·修改RegisterViewModel public class RegisterViewModel { [Required] [Display(Name ...
- [leetcode]_Remove Duplicates from Sorted Array II
题目:一个有序数组,要求保证数组中的每个元素不能超过2个. 输入:A = [1,1,1,2,2,3] 输出:length = 5, and A is now [1,1,2,2,3] 思路:双指针 ...
- [leetcode]_Palindrome Number
判断integer是否为回文串(负数全部不为回文串) 思路很直接,提取出integer中的每一位,一头一尾进行比较是否相同. 一次AC , 直接上代码: public boolean isPalind ...
- win php nginx 配置小细节
win下配置php Nginx 首先 下载 php-Windows版本.下载Nginx Windows 版本 1> php.ini-production 修改为 php.ini 让其成为php的 ...
- 转:浅谈关于b、h标签的优化技巧
<b>标签优化 <b>标签是一种加粗标记,作用就是加粗文章中的关键词,对于文章中重要的关键词加粗起到有利于用户阅读的作用.<b>标签的使用对于优化的作用是非常大的, ...