Question: How can I take this python function for filling in a shift table (it is already using Horspools and Boyer-Moore algorithms) And change it to
And change it to return a shift table that is a dictionary of letter-shift distance pairs. For example, the changed function def shiftTable(pattern) would return (once implemented correctly in Python) {a:4,b:2,e:1,r:3} def shiftTable(pattern): m-len(pattern) table = [] for k in range(256) table.append(m) for k in range(m-1): table(ord(pattern[k]))-m-k- 1 table - tuple(table) return table print(shiftTable(leader)) print(shiftTable(recorder)) print(shiftTable(TCCTATTCTT'))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
