Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This question is in regards to a string alignment Python function that I am work

ID: 3864240 • Letter: T

Question

This question is in regards to a string alignment Python function that I am working on. The function takes in two ASCII strings x and y, creates a table of length nx, by ny, then calculates an optimal cost between a set of 3 operations (indel, swap, substitute), and returns the completed table with the optimal costs filled in as values. Below is what I have so far. The base cases are filled in in row 1 and column 1. What I need now is to fill in the rest of the matrix by comparing the nodes directly above [i-1][j], directly to the left [i][j-1], left corner [i-1][j-1], and two to the left diagonally [i-2][j-2], and making [i][j] the minimum of those + the cost of the operation. Most of the issues I am having is figuring out the boundaries, because for example S[1][1] will not have an [i-2][j-2] value to check. It should be filled in as follows:

if [i-1][j] or [i][j-1] + 1 (cost of indel) are min --> [i][j] = random choice between [i-1][j] and [i][j-1] + 1 (cost of indel)

if [i-1][j-1] + 10 (cost of sub) is min --> [i][j] = [i-1][j-1] + 10 (cost of sub)

if [i-2][j-2] + 12 (cost of swap) is min --> [i][j] = [i-2][j-2] + 12 (cost of swap)

Below is what I have so far. The base cases should not change, and the rest of the table should fill in using those values.

Thanks for any help and let me know if you need any extra clarification.

def ali String (x, y) rows len (x) 1 cols len (y) S CO for i in range (cols) for i in range (rows) for i in range (rows) S Cil CO for i in range (cols) SCO] [i] return S table alignstring Exponential Polynomial for i in range (len (table) print (table [i]) StringAlignment C Users Chris AppData Local Programs Python Python 36-32 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] 6 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] [8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] 11 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] Process finished with exit code 0

Explanation / Answer

>>> for align, text in zip('', ['left', 'center', 'right']): ... '{0:{fill}{align}16}'.format(text, fill=align, align=align) ... 'left
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote