- 博客(4)
- 收藏
- 关注
数组的最大子数和问题
数组的最大子数和问题就是 有一个数组a,求a中和最大的连续子序列。 下面是看了《编程之美》的五种解法,计算复杂度和空间复杂度递减1 O(N^3)def maxsubsum(a): l = len(a) max = min(a) for i in range(l): for j in range(i, l): ...
2009-07-16 17:19:53
207
利用round函数的二分查找
二分查找是一种简单高效的搜索算法不过前提必须为进行搜索的数组为有序的一般情况下的实现方法中mid的取值为(low+high)/2的整数 但试想一下如果mid改为round值的话会不会提高搜索的效率呢下面为一般情况的实现 def binary_search(a, t, debug=False): l = 0 h = len(a) while l ...
2009-07-14 09:42:16
148
原创 “C#静态变量的诡异与恶心”之我见
今天看到了一个帖子题目说是"C#静态变量的诡异与恶心"我也说说我的看法,看下面的C#代码 1. using System; 2. 3. namespace StaticTest 4. { 5. class A 6. { 7. public static int X; 8. ...
2009-01-01 22:50:16
348
原创 Groovy的Closure
Groovy中有几个挺奇怪的地方this ownerdelegate下面为例子class Mother {int field = 1int foo() {return 2}Closure birth (param) {def local = 3def closure = {caller -> [this, field, foo(), local, p...
2008-12-14 22:43:38
159
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人