Find an algorithm to determine whether a regular language L

Find an algorithm to determine whether a regular language L contains a finite number of even length strings.

Solution

Take grammer G of L

1)remove null productions and unit productions from G and convert G to CNF. LET G\' be the resulting grammer. Let n be the number of non terminals in G\'.

2)Let k = 2^(n+1)

3)let i=k

4)take all even length strings i, and check if any one them belongs to L(G).if yes ,then return the answer no and stop.

5)i=i+2

6)if(i<=2*k), go to step 4

7)return yes and stop.

if this algorithm returns yes.. then L contain a finite number of even length strings

Find an algorithm to determine whether a regular language L contains a finite number of even length strings.SolutionTake grammer G of L 1)remove null production

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site