Position S + 1 in Text T) If 0 S N - M and T (S + 1 - . S + M) P (1 - . M) (That Is, If T (S + J) P (J), For 1 J M) - If
Position S + 1 in Text T) If 0 S N - M and T (S + 1 - . S + M) P (1 - . M) (That Is, If T (S + J) P (J), For 1 J M) - If
7. How many shifts does above algorithm takes to match if pattern P=0001 in the text
T=0000100011010001?
4 Shifts
The simplest of all exact string approaches is the naive approach, which scans the text T[l..n] from left to
right, comparing each character in the pattern P[l..m] to the text each iteration.
EXPRIMENT NO 9:
The components of FA model are Input tape, Read control and finite control.
2. Does it possible to have multiple transitions from one node to same node in finite automata? Why?
we can represent a FA graphically, with nodes for states, and arcs for transitions.
• If the next input char matches the label on a transition from the current state to a new state, go
to that new state
we preprocess the pattern and build a 2D array that represents a Finite Automata. Number of
states in FA will be M+1 where M is length of the pattern will be matching time.