File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 1+
12#coding:utf-8
23import numpy as np
34
@@ -51,11 +52,11 @@ def LCS_recursive(x,y):
5152 if x [- 1 ]== y [- 1 ]:
5253 return LCS_recursive (x [:- 1 ],y [:- 1 ])+ x [- 1 ]
5354 else :
54- return max_str (LCS_recursive (x [:- 1 ],y [- 1 ]),LCS_recursive (x [:],y [:- 1 ]))
55+ return max_str (LCS_recursive (x [:- 1 ],y [: ]),LCS_recursive (x [:],y [:- 1 ]))
5556
5657str1 = 'BCDABAB'
5758str2 = 'CBAABAABA'
58- # print LCS_recursive(str1,str2)
59+ print LCS_recursive (str1 ,str2 )
5960#CABAB
6061
6162def max_int (a ,b ):
@@ -75,7 +76,7 @@ def LCS_dynamic(x,y):
7576 line .append (0 )
7677
7778 for i in range (x_len + 1 ):
78- matrix .append (line [:])
79+ matrix .append (line [:])#浅拷贝害死人
7980 #print len(matrix),len(matrix[0])
8081 #矩阵零行零列填充完毕,填充矩阵剩余部分,矩阵从0行开始,矩阵第i行对应x[i-1]
8182 for i in range (1 ,x_len + 1 ):
You can’t perform that action at this time.
0 commit comments