Consider the following string match function that extracts a substring from the length of the pattern P in the string text T. It works for the pattern "why" and the text "whysaywhycatwhy" but fails with the text " why say why cat why" for the same pattern. Why does the "dum" string match function fail?
void dum(String P, String T) {
int N = T.length()-1;
int M = P.length();
int start = 0;
while(start < N){
String extract = T.substring(start, start+M);
if(extract.equals(P))
System.out.printf("Match at %d%n",start);
start = start + M;
}
}
a. The dum() function fails because it does not consider the overlap of the pattern within the extracted substring
b. The dum() function fails because it does not preprocess the string text
c. The dum() string match function fails because it does not hash efficiently
d. The dum() string match function fails because of the whitespace characters
a. The dum() function fails because it does not consider the overlap of the pattern within the extracted substring
This algorithm is like a naïve string search, except it is skipping ahead the length of the pattern P. This overlooks any possible matches from the overlapping text by so many characters 1 … to the length of the pattern P -1.
You might also like to view...
Match the following terms to their meanings:
I. ControlTips II. Report Wizard III. Propagate IV. Theme V. Auto Order A. Changes the tab order based on the position of the controls left to right and top to bottom B. Simplifies the process of creating professional-looking objects C. Disseminate or apply D. Display when an individual pauses the mouse pointer over a control E. An efficient way to begin creating a report
What reconfigurations would you expect to occur in the NTP synchronization subnet?
What will be an ideal response?