Program to build a DFA that accepts Strings ending with abc
Given a string, str consists of characters ‘a’, ‘b’ & ‘c’, the task is to check whether string str ends with “abc” or not. If it does, print ‘Accepted’ with state transitions, else print ‘Not Accepted’.Examples:Input: str = “cbabc”Output: AcceptedExplanation: c : q0–>q0b: q0–>q0a: q0–>q1b: q1–>q2c: q2–>q3The string “cbabc” is ending with ‘abc’. It is in final state q3. So the string is accepted.Input: str = “ababa” Output: Not acceptedExplanation: c: q0–>q0b: q0–>q0a: q0–>q1c: q1–>q0 The…