Convert one string S1 to another string S2 using only 3 types of operations

Q: Suppose we want to convert one string S1 to another string S2 using only 3 types of operations: 

-Insert(pos,char) (costs 8) 
-Delete(pos) (costs 6) 
-Replace(pos,char) (costs 8) 
Find the sequence of steps to convert S1 to S2 such that the cost to convert S1 to S2 is minimum. 
Eg. 'calculate' to 'late' - the possible operations are 
Delete(0) 
Delete(1) 
Delete(2) 
Delete(3) 
Delete(4) 
and the above sequence of operations costs 30.

 

A: some ideas

1) using levenshtein algorithm

2) Is this the minimum edit distance algorithm. You can look it up at various sources, some of them listed below (AKA "Levenshtein distance"): 

w_ww.stanford.edu/class/cs124/lec/med.pdf 
w_ww.csse.monash.edu.au/~lloyd/tildeAlgDS/Dynamic/Edit/ 
e_n.wikipedia.org/wiki/Levenshtein_distance

 

3) find longest common subseuqence, and use the avail operations on the rest of the characters.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章