Question

If the length of the array P is 4 and the length of the array T...

  1. If the length of the array P is 4 and the length of the array T is 14, how many shifts of P need to be performed in the string searching algorithm?

a. 9

b. 10

c. 11

d. 12

  1. What is the best case for the naive string search algorithm?

a. The first character of the pattern P isn't present in text T

b. All characters in pattern P are different

c. All characters in text T are different

d. Pattern P is half the size of text T


  1. What is the worst case for the naive string search algorithm?

a. All characters of the pattern P are present in text T

b. All characters of the pattern P and text T are the same

c. Pattern P is of size one

d. Text T is composed of pattern P concatenated N times


  1. How many borders does the string BABBAB have?

a. 0

b. 1

c. 2

d. 3

  1. Using the good suffix rule, if we have pattern P = "BABCABCAB" and we found a mismatch of T[i] with P[6], which index of P should we look into aligning with T[i]?

a. 0

b. 1

c. 3

d. 5

  1. Using only the bad character rule, how many shifts are performed when trying to find P = BAB in T = BACBABCAB?

a. 2

b. 3

c. 5

d. 8

7. Which string matching algorithms are better suited (or can be extended to be better suited) to work with a set of patterns (check all that apply)?

a. Aho-Corasick

b. Knuth-Morris-Pratt

c. Boyer-Moore

d. Rabin-Karp

  1. Which algorithms (in the implementations described in the course) can achieve a worst–case matching time of O(n) (check all that apply)?

a. Knuth-Morris-Pratt

b. Aho-Corasick

c. Boyer-Moore

d. Rabin-Karp

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer 1

Number of shifts = 14-4+1=11

Answer 2

The first character of the pattern P isn't present in text T

Answer 3

All characters of the pattern P and text T are the same

Answer 4

2

Sub-string which is both prefix and suffix of string is called border. In given string B and BAB both are borders.

Add a comment
Know the answer?
Add Answer to:
If the length of the array P is 4 and the length of the array T...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT