Question: Need help to practice it 1. Given two string a1a2an and b1b2bm, find their minimum odit distance 'The edit distance is the number of mismatchus
Need help to practice it
1. Given two string a1a2an and b1b2bm, find their minimum odit distance 'The edit distance is the number of mismatchus in an alignunent. For example, the minimum exlit distanos between the two strings "SUNNY" and "SNOWY" in the following alignment is 3: Likewise, the minimum exlit distanxe between "IN'LN'I'ON" and "EXECU'I'ION" is 5. (a) Reepresent the minimum edit distance between a1a2ak and b1b2b2 by a functivan natre. (b) Every function has variable(s). Now, it is time to decide on them, by which you can narrow down the problem intes sub problenns. 'This is usually straightforward, since the function's variables mostly correspond to the problem's input variahbe(s) or indicxs that make it esaier to construct sanalker sub problems. For example, the matrix indices in the Matrix chain Multiplication, the index of the last item we consider and the weight capacity in the Knapkark, or the lengths of the two sexpuences in langest Comunon Sulwenguence etc. Hevever, there are no variables related to the threse porsible: weights (ie. 1,4,5) but only the weight capsaity in the unboundesl Knapsiack besamse the weights are exnstants given to the problem. Write down the variahbes of your function in between parenthusis and define what your function represents as conplete and concise a possible in only one sentence, ias we did in diess (eg. Given a string Xi of length i and another string Y, of hength j,c(i,j) represents the length of their longest exanmem subexxpuenox in the knegest Cornunon Sukwuguence problesn.) NanneOfYourF'unction(.....) (c) We can start writing the right hand side of the fornulation in a recursive manner. Now spend a considerable assount of time to imagine how would an optimal alignment would kook like for two arbitrary stringe. Yes, it is astually two strings that are plased one above the other and expanded at sonne locations with a "-: Consider the last choice you would do to obtain this imaginative optimal solution. Yes, you are right! You scenario has two subcater: (1) (2) (3) ak In the finst somario, issumse that the odit distanse is minimizsel if only you don't put any of the first string's letters, but just put a "for the first string and put the soxwed string's last ketter. Given this assumption, write down the sub problem you must solve (i.e the same functivn with slightly different variahhes). Then, if the lost alignment wns as in the first seenario, the right hand side would be some function of the function you hawe written for the corresponding sub problesn. Write down the right hand side for the first swenario. NameOf Y ourF'unction ()= (d) In the sessond sexenario, assume that the exlit distanse is minimizasi if only you den't put any of the serond string's ketters, but just put a "-for the sexsond string and put the first string's last letter. Given this assumption, write down the sab problesn you must solve (ise- the same function with slightly different variahhes). 'Then, if the liest alignment was as in thes serond scenario, the right hand side would he some function of the function you have written for the coorresponding sab problen. Write down the right hand side for the sexxund srenario. NameOf YourF'untion ()= (c) In the third sxenario, issumse that the edit distance is minimizsed if only you put the last letters from both strings. Given this assumption, write down the sub problem you must solve: (ise. the same function with slightly different variahhes). Then, if the list alignnent was as in the third sxcnario, the right hand side would be: some function of the function you have written for the corresponding sub problem. 'This function has two legg: the one where the last letters are not the sarne, and the one where the liast letters are not the same. Write down the right hand side for the third scenario. NameOf Y ourF'unction ()= (f) Actually, we do not do any choice in dynamic: programming. What we must do is first to consider all possibilities liken abowe and hoose the minimum of thowe right hand sidhs. Now you are resuly to minimioxthem. Write down the whole formulation which codles:ts all the abowe right hand side func:tions into one ias a minimization function. NameO f YourF'unction ()=
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
