Similarity(X,Y):

For i = 0,...,m: SIM[i,0] = i*g
For j = 1,...,n: SIM[0,j] = j*g

For i = 1,...,m:

For j = 1,...,n:

SIM[i,j] = max(

SIM[i-1,j-1] + s(X[i],Y[j]),

SIM[i-1,j]+g,

SIM[i,j-1]+g

)

EndFor

EndFor

Return SIM[m,n]

wesam.teto.9
0
Newbie Poster

For i = 0,...,m: SIM[i,0] = i*g
For j = 1,...,n: SIM[0,j] = j*g

For i = 1,...,m:

For j = 1,...,n:

SIM[i,j] = max(

SIM[i-1,j-1] + s(X[i],Y[j]),

SIM[i-1,j]+g,

SIM[i,j-1]+g

)

EndFor

EndFor

Return SIM[m,n]

Edited
by wesam.teto.9

Jump to PostWell, it could be something like

`def Similarity(X,Y): for i in range(m+1): SIM[i,0] = ig for j in range(1, n+1): SIM[0,j] = jg for i in range(1, m+1): for j in range(1, n+1): SIM[i,j] = max( SIM[i-1,j-1] + s(X[i],Y[j]), SIM[i-1,j]+g, SIM[i,j-1]+g ) return SIM[m,n]`

but we …

wesam.teto.9
0
Newbie Poster

plz help me

Gribouillis
1,391
Programming Explorer
Team Colleague

Well, it could be something like

```
def Similarity(X,Y):
for i in range(m+1):
SIM[i,0] = ig
for j in range(1, n+1):
SIM[0,j] = jg
for i in range(1, m+1):
for j in range(1, n+1):
SIM[i,j] = max(
SIM[i-1,j-1] + s(X[i],Y[j]),
SIM[i-1,j]+g,
SIM[i,j-1]+g
)
return SIM[m,n]
```

but we don't know what `X, Y, SIM, ig, jg , g`

are, so it does not mean much.

Edited
by Gribouillis

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.