Question

In: Computer Science

Using the Boyer-Moore algorithm, find the Bad Match table for the below patterns.    i) Pattern1:   AABCACCCA...

Using the Boyer-Moore algorithm, find the Bad Match table for the below patterns.   

i) Pattern1:   AABCACCCA

ii) Pattern 2: CCCAAABBD

iii) Pattern3:  ABCABCBAD

iv) Pattern4:   BSDGSBAA

Solutions

Expert Solution

  1. pattern 1 = AABCACCCA

index = 012345678

length = 9

Letter A B C *
value 1 6 1 9

calculating the value of each letter in the pattern:

value formula is given by: max(1,length-index-1)

values :

A= max(1,9-0-1)=8

A= max(1,9-1-1)=7

B= max(1,9-2-1)=6// this value is updated in the table as it is the rightmost one

C= max(1,9-3-1)=5

A= max(1,9-4-1)=4

C= max(1,9-5-1)=3

C= max(1,9-6-1)=2

C= max(1,9-7-1)=1// this value is updated in the table as it is the rightmost one

A= max(1,9-8-1)=1 // this value is updated in the table as it is the rightmost one

2. pattern 1 = CCCAAABBD

index = 012345678

length = 9

Letter A B C D *
value 3 1 6 1 9

calculating the value of each letter in the pattern:

value formula is given by: max(1,length-index-1)

values :

C= max(1,9-0-1)=8

C= max(1,9-1-1)=7

C= max(1,9-2-1)=6// this value is updated in the table as it is the rightmost one

A= max(1,9-3-1)=5

A= max(1,9-4-1)=4

A= max(1,9-5-1)=3// this value is updated in the table as it is the rightmost one

B= max(1,9-6-1)=2

B= max(1,9-7-1)=1// this value is updated in the table as it is the rightmost one

D= max(1,9-8-1)=1 // this value is updated in the table as it is the rightmost one

3.pattern 1 = ABCABCBAD

index = 012345678

length = 9

Letter A B C D *
value 1 2 3 1 9

calculating the value of each letter in the pattern:

value formula is given by: max(1,length-index-1)

values :

A= max(1,9-0-1)=8

B= max(1,9-1-1)=7

C= max(1,9-2-1)=6

A= max(1,9-3-1)=5

B= max(1,9-4-1)=4

C= max(1,9-5-1)=3// this value is updated in the table as it is the rightmost one

B= max(1,9-6-1)=2// this value is updated in the table as it is the rightmost one

A= max(1,9-7-1)=1// this value is updated in the table as it is the rightmost one

D= max(1,9-8-1)=1 // this value is updated in the table as it is the rightmost one

4.pattern 1 = BSDGSBAA

index = 01234567

length = 8

Letter A B D G S *
value 1 2 5 4 3 8

calculating the value of each letter in the pattern:

value formula is given by: max(1,length-index-1)

values :

B= max(1,8-0-1)=7

S= max(1,8-1-1)=6

D= max(1,8-2-1)=5// this value is updated in the table as it is the rightmost one

G= max(1,8-3-1)=4// this value is updated in the table as it is the rightmost one

S= max(1,8-4-1)=3// this value is updated in the table as it is the rightmost one

B= max(1,8-5-1)=2// this value is updated in the table as it is the rightmost one

A= max(1,8-6-1)=1

A= max(1,8-7-1)=1// this value is updated in the table as it is the rightmost one

Only the right most values are to be filled into the table as per the algorithm


Related Solutions

How do you write a java program that implements Majority-Element using Boyer & Moore approach?
How do you write a java program that implements Majority-Element using Boyer & Moore approach?
The Question is about Boyer-Moor-Horspool algorithm. I cannot set the code of pre-processing: initialization of shift...
The Question is about Boyer-Moor-Horspool algorithm. I cannot set the code of pre-processing: initialization of shift table. the Pseudocode is 1: for ? from 0 to |∑|– 1 do 2: ?[?] ← ? 3: for ? from 0 to ?– 2 do 4: ?[?[?]] ← ?– 1– ? 5: ? ← 0 6: while ? + ? ≤ ? do 7: ? ← ? - 1 8: while ?[? + ?] = ?[?] do 9: ? ← ? - 1...
Match the descriptions below with the correct answer, using the letter codes shown in the table...
Match the descriptions below with the correct answer, using the letter codes shown in the table below. (8 points) A.    Realizable value B.    Percentage of receivables method C.      1/10, n/60 D.    Bad debt Expense E.      Aging of receivables F.       Direct write-off method G.     Operating cycle H.     Specific identification method I.        FOB shipping point J.        Time period assumption K.    n/10 EOM L.    Percentage of sales method M.   Permanent accounts N.    2/10, EOM O.    2/10, n/30 P.     FOB destination The economic life...
Align two sequences shown below using Needelman Wunsch algorithm. Use match score of 3, mismatch score...
Align two sequences shown below using Needelman Wunsch algorithm. Use match score of 3, mismatch score of -3 and gap penalty score of 2 (note, you should subtract this from the scoring function). Show: a) dynamic programming matrix with scores b) trace back pointers c) alignment score sequences: sequence 1: AGAGCTCACAA sequence 2: AGTAGCTTCCAAA
Using the information provided in the table below, find the probability of completing the project in...
Using the information provided in the table below, find the probability of completing the project in 46 weeks? Activity Immediate Predecessor(s) Optimistic Time Estimate (weeks) Most Likely Time Estimates (weeks) Pessimistic Time Estimates (weeks) A none 3 6 9 B A 3 5 7 C A 4 7 12 D B, C 4 8 10 E B, C 9 12 18 F D 5 10 13 G E 3 6 8 H F 1 5 12 I G 7 8...
Find the GCD (5796852, 4585268) using the Euclidian Algorithm..
Find the GCD (5796852, 4585268) using the Euclidian Algorithm..
Find the GCD (5796852, 4585268) using the Euclidian Algorithm..
Find the GCD (5796852, 4585268) using the Euclidian Algorithm..
Using the table below, find the real value of a $2,200 payment to be received each...
Using the table below, find the real value of a $2,200 payment to be received each year given the following CPI values. Next find the amount that this $2,200 should be adjusted to, in order to keep its real value at $2,200. Instructions: Round your answers to two decimal places. Year CPI Real value of $2200 Cost of living adjusted payment 2013 100 $2,200 $2,200 2014 103 2015 105 2016 110
Find the missing values in the table below using Boyle's Law. The units for pressure and...
Find the missing values in the table below using Boyle's Law. The units for pressure and volume can be any units, as long as they agree. Show all work. p1 V1 P2 V2 a) 488 torr 531 mL 1.88 atm ? b) ? 2.44 L 18.0 psi 1.35 gal
Using the table below, find the Probability of Ordering as a decimal and percent. Please show...
Using the table below, find the Probability of Ordering as a decimal and percent. Please show your work and formulas you would use in excel. # of pizzas ordered # of customers who ordered Probability of ordering (decimal value) Probability of ordering (as a percent) 1 8 2 9 3 6 4 1 5 0 6 0 7 0 8 0 Sum total 24
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT