Holooly Plus Logo

Question 10.2.1: Can the previous algorithm be used for any other string inst......

Can the previous algorithm be used for any other string instead of abcd?

Step-by-Step
The 'Blue Check Mark' means that this solution was answered by an expert.
Learn more on how do we answer questions.

A problem arises when the pattern contains repetitions. For example, suppose we are looking for substring ababc. Assume that a appears, then b, a, and b again. At this point, we are eagerly waiting for e. If the letter d appears instead, we should start from scratch. However, if the letter a appears, we still have a chance that b and c follow and the pattern is found.

Here is an illustration:

x y z  a b a b a b c …  ← input string

a  b a b c            ← pattern was expected here

a b a b c              ← but it is here

In other words, at the point

\begin{array}{rllllll|llll} \mathrm{x} & \mathrm{y} & \mathrm{z} & \mathrm{a} & \mathrm{b} & \mathrm{a} & \mathrm{b} & \quad \quad \quad \ \ \ \quad\leftarrow \text { input string } \\ & & & \mathrm{a} & \mathrm{b} & \mathrm{a} &\mathrm{b} &\mathrm{c} \quad \quad \quad \quad \leftarrow \text { pattern was expected here } \\ & & & && \mathrm{a} & \mathrm{b} & \mathrm{a} \quad \mathrm{b} \quad \mathrm{c} \quad\leftarrow \text { but it is here } \end{array}

there are two possible pattern positions to be tested.

Related Answered Questions

Question: 10.7.11

Verified Answer:

Assume that the nondeterministic automaton has ver...
Question: 10.7.12

Verified Answer:

In the Floyd algorithm for the shortest path (see ...
Question: 10.7.9

Verified Answer:

This automaton is constructed inductively, followi...
Question: 10.7.8

Verified Answer:

To prove this, we need the notion of a nondetermin...
Question: 10.7.6

Verified Answer:

((a\mid b\mid c)\ast bac (a \mid b \mid c)...
Question: 10.7.5

Verified Answer:

The expression b∗ defines the set of all strings w...