{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

DynProgEditDistance - Edit Distance The problem of finding...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Edit Distance The problem of finding an edit distance between two strings is as follows: Given an initial string s, and a target string t, what is the minimum number of chances that have to be applied to s to turn it into t. The list of valid changes are: 1) Inserting a character 2) Deleting a character 3) Changing a character to another character. In initially looking for a recursive solution, you may think that there are simply too many recursive cases. We could insert a character in quite a few locations! (If the string is length n, then we can insert a character in n+1 locations.) However, the key observation that leads to a recursive solution to the problem is that ultimately, the last characters will have to match. So, when matching one word to another, on consider the last characters of strings s and t. If we are lucky enough that they ALREADY match, then we can simply "cancel" and recursively find the edit distance between the two strings left when we delete this character from both strings. Otherwise, we MUST make one of three changes:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}