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 ...
随机推荐
- EasyUI 后台管理系统
基础功能版: 测试地址:http://dev.blueapp.cn/index.php/2014/07/03/101/ 用户名:admin密码:123456 有问题可一起探讨,源码后期将放出 一直未测 ...
- java生成4个不同的随机数
package lianxi; import java.util.Random; public class suijishu { public static void main(String[] ar ...
- 软件工程 speedsnail 第二次冲刺8
20150525 完成任务:障碍物整体设计,实现一页多次布局: 遇到问题: 问题1 与现有资源冲突 解决1 未解决 明日任务: 蜗牛碰到线后速度方向的调整:(做优化)
- C#中判断字符串中包含某个字符
C#判断字符串是否存在某个字符,如果存在进行替换. //定义一个字符串 string str=".net/Java/asp.net"; //检验“/” if(str.Cont ...
- 使用JavaScript获取Request中参数的值
本人很少写博客,有不正确的地方还希望大家多多指导. 假设现在有一个URL,如下. http://www.jacky.com/?id=1101&name=jacky 如何通过JS访问到id和na ...
- php static延迟静态绑定
如果你是一个懒惰的程序员,你看到以下代码可能会恼火 abstract class U{ } class u1 extends U{ public static function create(){ r ...
- WordPress 主题开发 - (七) 让主题更安全 待翻译
We're just about ready to start building our theme's template files. Before we do this, however, it' ...
- 将Tab栏居中的方法
原始tab: 居中后的tab(边缘效果是截图的问题): 改变方法如下: 找到Android SlidingTabLayout源代码,在Android SlidingTabLayout源代码中有一个方法 ...
- js控制div动起来
代码: <html> <head> <title>让div动的测试</title> <script language="javascri ...
- C#使用SQL存储过程完整流程
存储过程就是固化在SQL数据库系统内部的SQL语句,这样做的好处是可以提高执行效率.提高数据库的安全性.减少网络流量.接下来就讲解如何在数据库中建立一个存储过程. 打开SQL2055数据库,展开“数据 ...