edited by
471 views
0 votes
0 votes
Give an algorithm that takes a DFA  $A$ and computes the number of strings of length $n$ $($for some given $n$ not related to the number of states of $A)$ accepted by $A.$Your algorithm should be polynomial in both $n$ and the number of states of $A.$
edited by

1 Answer

0 votes
0 votes

Let R(k)ijm be the number of paths from state i to state j of length m that go through no state numbered higher than k. We can compute these numbers, for all states i and j, and for m no greater than n, by induction on k.

Basis: R0ij1 is the number of arcs (or more precisely, arc labels) from state i to state jR0ii0 = 1, and all other R0ijm's are 0.

Induction: R(k)ijm is the sum of R(k-1)ijm and the sum over all lists (p1,p2,...,pr) of positive integers that sum to m, of R(k-1)ikp1 * R(k-1)kkp2 *R(k-1)kkp3 *...* R(k-1)kkp(r-1) * R(k-1)kjpr. Note r must be at least 2.

The answer is the sum of R(k)1jn, where k is the number of states, 1 is the start state, and j is any accepting state.

Related questions

0 votes
0 votes
0 answers
3
1 votes
1 votes
0 answers
4
admin asked Apr 3, 2019
181 views
Convert the following regular expressions to NFA's with $\in-$transactions. $01^{*}$$(0+1)01$$00(0+1)^{*}$Eliminate $\in-$transactions from your $\in-NFA’s$