Question: Where can I add counters to this Python code that implements Horspools algorithm for finding a pattern in a text. We are only supposed to

Where can I add counters to this Python code that implements Horspools algorithm for finding a pattern in a text. We are only supposed to count key comparisons(dont count anything in the creation of the shift table) . The output should be a list whose first element is the position of the first character of the first match and whose second element is the number of comparisons performed. If done correctly, after running HorspoolMatching(barber,jim saw me in a barbershop, we should have an out put of [16,12]
 Where can I add counters to this Python code that implements

def HorspoolMatching (pattern, text): m= len (pattern) n len (text) if mn: return -1 4 5 6 07 28 39 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) k=m-1 counter=0 while k= 0 and text[1]-pattern [j]: 40 41 if j k += -1: return i+1 table [ord (text [k])] 42 43 return 1<:>

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!