• If dealing with a pushdown automaton, convert it into a CFG.
  • Convert the CFG into Chomsky normal form.
  • Now any string of length n generated by the resulting grammar must have a derivation of with exactly 2n-1 steps. (Why?)
    Therefore it suffices to list all possible derivations of length 2n-1 and check if any of them derives the given string.