Question: Problem 1. (Calculating Edit Distance Using Dynamic Programming) A direct implementation of the above recursive scheme will work, but it is spectacularly inefficient lf both

Problem 1. (Calculating Edit Distance Using Dynamic Programming) A direct implementation of the above recursive scheme will work, but it is spectacularly inefficient lf both input strings have N characters, then the number of recursive calls will exceed 2N. To overcome this performance bug, we use dynamic programming. Dynamic programming is a powerful algorithmic paradigm, first introduced by Bellman in the context of operations research, and then applied to the alignment of biological sequences by Needleman and Wunsch. Dynamic programming now plays the leading role in many computational problems, including control theory, financial engineering, and bioinformatics, including BLAST (the sequence alignment program almost universally used by molecular biologists in their experimental work). The key idea of dynamic programming is to break up a large computational problem into smaller subproblems, store the answers to those smaller subproblems, and, eventually, use the stored answers to solve the original problem. This avoids computing the same quantity repeatedly. Instead of using recursion, use a nested loop that calculates opt i][ in the right order so that opt [i+1] [j+1], opt[i+1] [j, and opt [ i ] [ j + 1 ] are all computed before we try to compute opt [ i] [ j ] . Write a program edit_distance.py that reads strings x and y from standard input and computes the edit-distance matrix opt as described above. The program should output x, y, the dimensions (number of rows and columns) of opt, and opt itself, using the following format The first and second lines should contain the strings x and y The third line should contain the dimensions of the opt matrix, separated by a space . The following lines should contain the rows of the opt matrix, each ending in a newline character. Use stdio. writef ( ) with the format string ' %3d' to write out the elements of the matrix Page 4 of 7 CS110 Project 2 Ryan Koh python edit_distance.py
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
