python算法实践2 shell排序
#shell排序
def ShellPass(mylist, d):
size = len(mylist)
i = d
while i < size:
if mylist[i] < mylist[i - d]:
tmp = mylist[i]
j = i - d
mylist[j + d] = mylist[j]
j = j - d
while j >= 0 and mylist[j] > tmp:
mylist[j + d] = mylist[j]
j = j - d
mylist[j + d] = tmp
i = i + d
def ShellSort(mylist):
n = len(mylist)
while n > 1:
n = n // 3 + 1
ShellPass(mylist, n)
mylist0 = [12, 11, 13, 1, 2, 4, 3, 77, 44]
ShellSort(mylist0)
print(mylist0)
相关文档:
def test2():
32 db = util.DBUnit('mysql_ab') &nb ......
来源:
作者:
灵剑
1.python 字符串通常有单引号('...')、双引号(...)、三引号(...)或('''...''')包围,三引号包含的字符串可由多行组成,一般可表示大段的叙述性字符串。在使用时基本没有差别,
1.python
字符串通常有单引号('...')、双引号("...")、三引号("""... ......
2008-12-21
python类型转换、数值操作
关键字: python类型转换、数值操作
python类型转换
Java代码
函数 描述
int(x [,base ])   ......
And last here is the overload operators example:
# map() takes two (or more) arguments, a function and a list to apply the function to
# lambda can be put anywhere a function is expected
# map() calls lambada for every element in the self list
# since Vector has overloaded __getitem__ and __len_ ......