Skip to content

Commit 9d4f523

Browse files
committed
重构代码
1 parent 65c455d commit 9d4f523

10 files changed

Lines changed: 27 additions & 4 deletions

ch02_sort/at206_bucket_sort.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
然后循环n个桶,对每个桶排序,采用插入排序算法
1111
"""
1212
from math import floor
13-
from ch01_basic.at003_insert_sort import insertSort
13+
14+
from ch02_sort.at103_insert_sort import insertSort
15+
1416
__author__ = 'Xiong Neng'
1517

1618

ch02_sort/at209_imin_select2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
Desc : 顺序统计量的选择算法(最坏情况下O(n))
77
利用中位数的中位数作为pivot划分数组
88
"""
9-
from ch01_basic.at003_insert_sort import insertSort
10-
from random import shuffle
9+
from ch02_sort.at103_insert_sort import insertSort
1110

1211
__author__ = 'Xiong Neng'
1312

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22
# -*- encoding: utf-8 -*-
3-
# 电梯调度算法
3+
# 动态规划:电梯调度算法
44
"""
55
Topic: sample
66
Desc : 电梯调度算法

ch04_dynamic/at404_lcs.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
# -*- encoding: utf-8 -*-
3+
# 最长公共子序列:longest-common-subsequence
4+
"""
5+
Topic: 一个子序列代表,将一个序列中去掉若干元素后得到的序列,可以间隔。
6+
公共子序列就是,序列A和序列B的公共子序列
7+
最长公共子序列就是,公共子序列里面长度最长的。
8+
Desc :
9+
"""
10+
11+
def lcs(arr1, arr2):
12+
m = len(arr1)
13+
n = len(arr2)
14+
b = [[-1 for kk in range(0, n)] for kk in range(0, m)]
15+
c = [[0 for kk in range(0, n)] for kk in range(0, m)]
16+
17+
return None
18+
19+
if __name__ == '__main__':
20+
x = ['A', 'B', 'D', 'A', 'C', 'K']
21+
y = ['B', 'D', 'D', 'E', 'C', 'K', 'M']
22+
lcs(x, y)

0 commit comments

Comments
 (0)