Define a finite automaton accepting the language below
It helps to think of finite automata in terms of their states. That is, think of what should each state represent for designing a finite automaton. In fact, it helps to "be the automaton". For this problem, you could start like, Initially, we are at the "start" state, say S1. Now we see an "a", what do we do? We have matched part of the ab substring, so we now need to check if we get a "b" next in line. So this state "waiting for a "b"" is a new state, say S2. Now at S1, we get a "b". This doesn't change anything, we still haven't got an "a" so we continue to remain in S1, waiting for an "a" to match and move to S2. At S2 if we get a "b", we have an "ab" now, so I move to a new "matched ab" state, say S3. At S2, if we get an "a", then we are still in the "matched a" state, and continue to wait for B. Try to think this way, and you shall probably find it easier to design automata, I found this intuition helpful.