摘要: 对于T(n) = a*T(n/b)+c*n^k;T(1) = c 这样的递归关系,有这样的结论:if (a > b^k) T(n) = O(n^(logb(a)));logb(a)b为底a的对数if (a = b^k) T(n) = O(n^k*logn);if (a < b^k) T(n) = O(n^k); 阅读全文
posted @ 2013-09-21 20:19 冰点猎手 阅读(298) 评论(0) 推荐(0) 编辑
摘要: Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a function to determine if a given target is in the array. class Solution {public: bool search(int A[], int n, int target) { // Start typing your C/C+. 阅读全文
posted @ 2013-09-21 12:23 冰点猎手 阅读(106) 评论(0) 推荐(0) 编辑
摘要: 1 字符串转换为整数 itao2 strstr3 string的构造函数 、析构函数、 拷贝构造函数、 复制函数4Char ** StrToK(const char* S1,const char* S2)实现该函数,功能:S2将S1字符串截断后,分别输出截断的字符串。举例例如S1=abcdefg, S2=be,将a,cd,fg三个字符串用指向指针的指针返回。 阅读全文
posted @ 2013-09-21 10:50 冰点猎手 阅读(140) 评论(0) 推荐(0) 编辑
摘要: int sum(int a, int b){ int carry = 1; int res = 0 ; while(carry != 0){ res = a^b; carry = (a&b)<<1; a = res; b = carry; } return res;} 阅读全文
posted @ 2013-09-21 10:16 冰点猎手 阅读(131) 评论(0) 推荐(0) 编辑
摘要: class Temp{public: Temp(){ ++N; sum+=N; } static void Reset(){ N = 0; sum = 0; } static int getSum(){ return sum; }private: static int N; static int sum;};int Temp::N = 0;int Temp::sum = 0;int sum(int n){ Temp::reset(); Temp * a = new ... 阅读全文
posted @ 2013-09-21 10:10 冰点猎手 阅读(162) 评论(0) 推荐(0) 编辑
摘要: bool compare(const void * a, const void * b){ return *(int *)a <= *(int *)b;}bool IsContinues(int number[], int length){ if(number == NULL || length <1) return false; qsort(number,length, sizeof(int),compare); int numberofzero =0; int cur = 0; while(cur < length && number[cur] == 0. 阅读全文
posted @ 2013-09-21 09:34 冰点猎手 阅读(150) 评论(0) 推荐(0) 编辑