EDIT: as templatetypedef commented, this problem is to find out if a DFA has a synchronizing word (a.k.a. "reset sequence").
Given a finite state set $Q$, a finite alphabet $\Sigma$, and a transition function $\delta : Q \times \Sigma \rightarrow Q$, I want to find out if there is a state $q_f \in Q$ and a string $s \in \Sigma^*$ such that for every state $q_0 \in Q$ (including $q_f$), the DFA $\left( Q, \Sigma, \delta, q_0, \left\{ q_f \right\} \right)$ accepts $s$. ($q_0$ is the initial state; $q_f$ is the only accepting state.)
In other words, if you think of a string as a list of directions for navigating the DFA, I want to find out if there is a list of directions that takes you to the same state no matter where you started. (Knowing the existence is enough; I do not need to know the state or the string itself.)
I have tried this algorithm:
Reverse the transitions in $\delta$ to form an NFA.
Convert the NFA into a DFA where each state corresponds to a subset of the NFA's states.
For each state $q \in Q$, search the new DFA for a path from $\left\{ q \right\}$ to $Q$. (I just do a depth first search.)
Iff one of these searches is successful, then the answer to the question is "yes".
This algorithm is correct, but it runs in exponential time and space, and it takes too long to complete. (My input DFAs have tens of states.) Note that I do not actually construct a DFA from the NFA -- instead, I perform the search on the NFA and I remember which subsets of its states I have visited.
Is there a way to improve my algorithm? Are there other algorithms to solve this problem? (Or at least, algorithms that would be useful?) Are there any properties of automata and regular languages that I can take advantage of?