404 views
0 votes
0 votes
Given an algorithm to tell whether a regular language
L contains at least 100 strings

1 Answer

Best answer
2 votes
2 votes
There is a cool trick which i got to know from CLRS (Ex 22.4-2).

Since, this is a regular language , $\exists$ a dfa for it , we can have a graphical representation for it.

Check if the graph has a cycle , if yes then halt.

Otherwise,

Add an additional parameter , called weights to each vertex. Assign weights 1 to any of the final vertices first and assign it weight 1.

Create a topological ordering of it and traverse it from the reverse , i.e destination to source, for a node v , weights[v]=$\Sigma$ weights[v]+weights[w], where w are the adjacent vertices of v. Finally when it completes , check the weights of the initial state vertex. If it is $\geq$ 100, then stop , otherwise repeat for all final states and check whether it exceeds 100 or not. You will finally have your answer.
selected by

Related questions

0 votes
0 votes
1 answer
2
Lakshman Bhaiya asked Dec 27, 2018
576 views
Construct a minimal DFA which accepts set of all strings over {a,b}, such that$1)$Second symbol from $RHS$ should be $‘a’$$2)$Third symbol from $RHS$ should be $‘a�...
1 votes
1 votes
2 answers
3
aditi19 asked Dec 14, 2018
1,538 views
DFA in which 01 and 10 have equal number of occurrences
3 votes
3 votes
1 answer
4
aditi19 asked Dec 10, 2018
2,285 views
in reversal of DFA if there are more than one final states then which one will be made the initial state? a DFA can have only one initial state