Question

In: Computer Science

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

SHOW WORK

. Using the Boyer-Moore algorithm, find the Bad Match table for the below patterns.                                                                                                   (8 points)

i) Pattern1:   AABCACCCA

ii) Pattern 2: CCCAAABBD

iii) Pattern3:  ABCABCBAD

iv) Pattern4:   BSDGSBAA

SHOW WORK

Solutions

Expert Solution

i) Pattern1:   AABCACCCA

Steps 1: Index each character in pattern starting from 0.

Pattern A A B C A C C C A
Index 0 1 2 3 4 5 6 7 8

step 2:take length of the pattern, here that is 9.

step 3: calculate max(1,length-index-1)

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

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

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

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

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

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

value(A)=max(1,9-6-1)=max(1,2)=2

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

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

If the same characters repeats, update the table by the values from the new character

Pattern A B C *
Values 1 6 3 9

ii) Pattern 2: CCCAAABBD

Steps 1: Index each character in pattern starting from 0.

Pattern C C C A A A B B D
Index 0 1 2 3 4 5 6 7 8

step 2:take length of the pattern, here that is 9.

step 3: calculate max(1,length-index-1)

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

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

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

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

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

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

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

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

value(D)=max(1,9-0-1)=max(1,0)=1

If the same characters repeats, update the table by the values from the new character

Pattern C A B D *
Values 6 3 1 1 9

iii) Pattern3:  ABCABCBAD

Steps 1: Index each character in pattern starting from 0.

Pattern A B C A B C B A D
Index 0 1 2 3 4 5 6 7 8

step 2:take length of the pattern, here that is 9.

step 3: calculate max(1,length-index-1)

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

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

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

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

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

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

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

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

value(D)=max(1,9-0-1)=max(1,0)=1

If the same characters repeats, update the table by the values from the new character

Pattern A B C D *
Values 1 2 3 1 9

iv) Pattern4:   BSDGSBAA

Steps 1: Index each character in pattern starting from 0.

Pattern B S D G S B A A
Index 0 1 2 3 4 5 6 7

step 2:take length of the pattern, here that is 9.

step 3: calculate max(1,length-index-1)

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

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

value(D)=max(1,8-2-1)=max(1,6)=5

value(G)=max(1,8-3-1)=max(1,5)=4

value(S)=max(1,8-4-1)=max(1,4)=3

value(B)=max(1,8-5-1)=max(1,3)=2

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

value(A)=max(1,8-7-1)=max(1,0)=1

If the same characters repeats, update the table by the values from the new character

Pattern B S D G A *
Values 2 3 5 4 1 8

Related Solutions

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
Using the Boyer-Moore algorithm, find the Bad Match table for the below patterns. Pattern1: AABCACCCA Pattern...
Using the Boyer-Moore algorithm, find the Bad Match table for the below patterns. Pattern1: AABCACCCA Pattern 2: CCCAAABBD Pattern3: ABCABCBAD Pattern4: BSDGSBAA
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
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?
Determine the output of the algorithm below the number of assignment operations in each (show work)...
Determine the output of the algorithm below the number of assignment operations in each (show work) the number of print operations in each (show work) the complexity of each algorithm in terms of Big O notation (show work) 3. Let n be a given positive integer, and let myList be a three-dimensional array with capacity n for each dimension. for each index i from 1 to n do { for each index j from 1 to n/4 do { for...
SHOW WORK Sort the given keys using Counting sort algorithm. Also write the algorithm.          5, 2,...
SHOW WORK Sort the given keys using Counting sort algorithm. Also write the algorithm.          5, 2, 3, 1, 0, 2, 1, 5, 0                                                                  SHOW WORK!
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
Please show all work and formula: Please use the information on the table below to answer...
Please show all work and formula: Please use the information on the table below to answer this question. Security                       Actual Return             Beta A                                 12%                             1.2 B                                  10%                             1.0 C                                  14%                             1.4 Assume the risk-free interest rate is 1% and the market risk premium is 5.5%. An investor would like to invest $40,000 in Security A, $25,000 in security B and $50,000 in Security C. Find the portfolio’s expected return. Find the portfolio’s actual return. Based on your answers to a...
Answer & show work andswer and show work answer n show work Using a sample of...
Answer & show work andswer and show work answer n show work Using a sample of 20 people, the testing agency found that 14 of them had better protection than that provided by the competitor. Do you have enough evidence to say/claom that your suncreen lotion provides better protection than the competitiors in a majority of cases? Use alpha = 0.01 to answer. 1. What are the apporiate hypotheses for situation? 2. the appropriate rejection rule is? 3. the calculated...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT