Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote