# Why is this not recognized by a DFA?

I am still confused over my professor's explanation on why this problem is not a DFA.

The Problem: Explain why $$L = \{p^kq^k \mid k>0\}$$ cannot be recognized by a DFA

My professor explained it as that it was because the DFA could not store the $$k$$ iterations in memory. But I still don't get it. In my mind, you just draw states $$k$$ number of times for $$p$$ and then $$q$$.

What's wrong with my logic?

The actual claim is that there is no DFA for the language $$\{p^kq^k\mid k\geq 0\}$$. Such an automaton would have to accept every string of the form $$p^kq^k$$ for any $$k$$, and reject every other string.
For any one fixed value of $$k$$, you're absolutely right that you can use $$2k$$ states to count off the $$p$$'s and the $$q$$'s. However, to recognize the language, the automaton would have to be able to do this for infinitely many different values of $$k$$, which would require infinitely many states by this method. Of course, that's not allowed in a deterministic finite automaton.