Question: Suppose that pattern P and text T are randomly chosen strings of length m and n, respectively, from the d-ary alphabet ? d = {0,

Suppose that pattern P and text T are randomly chosen strings of length m and n, respectively, from the d-ary alphabet ?d = {0, 1, . . . , d ? 1}, where d ? 2. Show that the expected number of character-to-character comparisons made by the implicit loop in line 4 of the naive algorithm is

1d- ( + 1)- < 2( + 1) 1-d-1

over all executions of this loop. (Assume that the naive algorithm stops comparing characters for a given shift once it finds a mismatch or matches the entire pattern.) Thus, for randomly chosen strings, the naive algorithm is quite efficient.

1d- ( + 1)- < 2( + 1) 1-d-1

Step by Step Solution

3.42 Rating (174 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

This is a probability question assume ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Introduction to Algorithms Questions!