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.

转载于:https://www.cnblogs.com/yayagamer/archive/2013/04/24/3040608.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值