Similarity(X,Y):
For i = 0,...,m: SIM[i,0] = ig
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]

Recommended Answers

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 …

Jump to Post

All 2 Replies

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.

Be a part of the DaniWeb community

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