Complementation process in DFA
Last Updated :
11 Jul, 2025
Prerequisite – Design a Finite automata
Suppose we have a DFA that is defined by ( Q, \Sigma , \delta , q0, F ) and it accepts the language L1. Then, the DFA which accepts the language L2 where L2 = ̅L1', will be defined as below:
( Q, \Sigma, \delta, q0, Q-F )
The complement of a DFA can be obtained by making the non-final states as final states and vice-versa. The language accepted by the complemented DFA L2 is the complement of the language L1.
Example-1:
L1: set of all strings over {a, b} of even length
L1 = {\epsilon, ab, aa, abaa, aaba, ....}
L2: set of all strings over {a, b} of odd length
L2 = { a, b, aab, aaa, bba, bbb, ...}
Here, we can see that L2 = ̅L1
Lets first draw the DFA for L1 that accepts the strings of even length.

Now, for designing the DFA for L2, we just need to complement the above DFA. We will change the non-final states as final state and the final states as non-final states.

This is our required complemented DFA.
Example-2:
L1: set of all strings over {a, b} starting with 'a'.
L1 ={ a, ab, aa, aba, aaa, aab, ..}
L2: set of all strings over {a, b} not starting with 'a'.
L2 ={ \epsilon, b, ba, bb, bab, baa, bba, ...}
Here, we can see that L2 = ̅L1
Lets first draw the DFA for L1 that accepts the set of all strings over {a, b} starting with 'a'

Now, for designing the DFA for L2, we just need to complement the above DFA. We will change the non-final states as final state and the final states as non-final states.

This is our required complemented DFA that accepts the strings that are not starting with 'a'.
Note: Regular languages are closed under complement (i.e Complement of regular language will also be regular).
Explore
Automata _ Introduction
Regular Expression and Finite Automata
CFG
PDA (Pushdown Automata)
Introduction of Pushdown Automata
5 min read
Pushdown Automata Acceptance by Final State
4 min read
Construct Pushdown Automata for given languages
4 min read
Construct Pushdown Automata for all length palindrome
6 min read
Detailed Study of PushDown Automata
3 min read
NPDA for accepting the language L = {anbm cn | m,n>=1}
2 min read
NPDA for accepting the language L = {an bn cm | m,n>=1}
2 min read
NPDA for accepting the language L = {anbn | n>=1}
2 min read
NPDA for accepting the language L = {amb2m| m>=1}
2 min read
NPDA for accepting the language L = {am bn cp dq | m+n=p+q ; m,n,p,q>=1}
2 min read
Construct Pushdown automata for L = {0n1m2m3n | m,n ⥠0}
3 min read
Construct Pushdown automata for L = {0n1m2n+m | m, n ⥠0}
2 min read
NPDA for accepting the language L = {ambncm+n | m,n ⥠1}
2 min read
NPDA for accepting the language L = {amb(m+n)cn| m,n ⥠1}
3 min read
NPDA for accepting the language L = {a2mb3m|m>=1}
2 min read
NPDA for accepting the language L = {amb2m+1 | m ⥠1}
2 min read
NPDA for accepting the language L = {aibjckdl | i==k or j==l,i>=1,j>=1}
3 min read
Construct Pushdown automata for L = {a2mc4ndnbm | m,n ⥠0}
3 min read
NPDA for L = {0i1j2k | i==j or j==k ; i , j , k >= 1}
2 min read
NPDA for accepting the language L = {anb2n| n>=1} U {anbn| n>=1}
2 min read
NPDA for the language L ={wÐ{a,b}* | w contains equal no. of a's and b's}
3 min read
Turing Machine
Decidability
TOC Interview preparation
TOC Quiz and PYQ's in TOC