Shortest path to transform one word into another

后端 未结 9 2309
梦如初夏
梦如初夏 2020-12-01 00:44

For a Data Structures project, I must find the shortest path between two words (like \"cat\" and \"dog\"), changing only one letter at a time. We a

9条回答
  •  南方客
    南方客 (楼主)
    2020-12-01 00:47

    What you are looking for is called the Edit Distance. There are many different types.

    From (http://en.wikipedia.org/wiki/Edit_distance): "In information theory and computer science, the edit distance between two strings of characters is the number of operations required to transform one of them into the other."

    This article about Jazzy (the java spell check API) has a nice overview of these sorts of comparisons (it's a similar problem - providing suggested corrections) http://www.ibm.com/developerworks/java/library/j-jazzy/

提交回复
热议问题