

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Dynamic programming is essentially recursion without repetition. Developing a dynamic programming algorithm generally involves two separate steps:
Dynamic programming algorithms need to store the results of intermediate subproblems. This is often but not always done with some kind of table. We will now cover a number of examples of problems in which the solution is based on dynamic programming strategy.
The words “computer” and “commuter” are very similar, and a change of just one letter, p-¿m, will change the first word into the second. The word “sport” can be changed into “sort” by the deletion of the ‘p’, or equivalently, ‘sort’ can be changed into ‘sport’ by the insertion of ‘p’. The edit distance of two strings, s1 and s2, is defined as the minimum number of point mutations required to change s1 into s2, where a point mutation is one of:
For example, the edit distance between FOOD and MONEY is at most four:
There are numerous applications of the Edit Distance algorithm. Here are some examples:
Spelling Correction If a text contains a word that is not in the dictionary, a ‘close’ word, i.e. one with a small edit distance, may be suggested as a correction. Most word processing applications, such as Microsoft Word, have spelling checking and correction facility. When Word, for example, finds an incorrectly spelled word, it makes suggestions of possible replacements.
Plagiarism Detection If someone copies, say, a C program and makes a few changes here and there, for example, change variable names, add a comment of two, the edit distance between the
source and copy may be small. The edit distance provides an indication of similarity that might be too close in some situations.
Computational Molecular Biology DNA is a polymer. The monomer units of DNA are nucleotides, and the polymer is known as a “polynucleotide.” Each nucleotide consists of a 5-carbon sugar (deoxyribose), a nitrogen containing base attached to the sugar, and a phosphate group. There are four different types of nucleotides found in DNA, differing only in the nitrogenous base. The four nucleotides are given one letter abbreviations as shorthand for the four bases.
Speech Recognition Algorithms similar to those for the edit-distance problem are used in some speech recognition systems. Find a close match between a new utterance and one in a library of classified utterances.
A better way to display this editing process is to place the words above the other:
The first word has a gap for every insertion (I) and the second word has a gap for every deletion (D). Columns with two different characters correspond to substitutions (S). Matches (M) do not count. The Edit transcript is defined as a string over the alphabet M, S, I, D that describes a transformation of one string into another. For example
S D I M D M 1+ 1+ 1+ 0+ 1+ 0+ = 4
In general, it is not easy to determine the optimal edit distance. For example, the distance between ALGORITHM and ALTRUISTIC is at most 6.
Is this optimal?