Algorithm PatternFind (A, lengthA, B, lengthB) Pre: ‘A’ is an arrayof characters
ID: 3618950 • Letter: A
Question
Algorithm PatternFind (A, lengthA, B, lengthB)
Pre: ‘A’ is an arrayof characters of length ‘lengthA’ ,
‘B’ is an array of characters of length‘lengthB’
Post: prints out all the positions of the array where thepattern B can be found starting at that position of A.
for (j <- 0; j < lengthA-lengthB+1; j++)
result <- determine ifA[j] through A[j+lengthB-1] is equal to B[0] throughB[lengthB-1]
if (result = 1)
print j
end if
Explanation / Answer
if (result = 1)
print j
end if
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.