I have to realize an NFA that recognizes the language of strings on the alphabet {a, b} ending with: bb, ba, baa. I thought that there must be the following states:
$q_0$: the string ends with bb.
$q_1$: the string ends with ba.
$q_2$: the string ends with baa.
Is right the definition of the states? Or missing some state?
Thanks.
As you seem to understand, the states in a FA can be designed to correspond to having seen a particular form of input. One solution (not with the minimal number of states, but easier to understand) uses five states:
Since we're looking for $ba, bb, baa$ at the end of the input, we'll have no moves from $q_3$ and $q_4$ and only an $a$ transition from $q_2$, to handle the possibility that the input ends after having seen $\dots baa$.
The transition table for this NFA is $$ \begin{array}{ccc} & \mathbf{a} & \mathbf{b}\\ q_0 & \{q_0\} & \{q_0, q_1\}\\ q_1 & \{q_2\} & \{q_3\}\\ q_2 & \{q_4\} & \varnothing\\ q_3 & \varnothing & \varnothing\\ q_4 & \varnothing & \varnothing \end{array} $$
You might want to try designing a NFA for this language with four, rather than five states.