Regular Languages and Finite Automata MCQ Quiz - Objective Question with Answer for Regular Languages and Finite Automata - Download Free PDF

Last updated on Jul 3, 2025

Latest Regular Languages and Finite Automata MCQ Objective Questions

Regular Languages and Finite Automata Question 1:

Which of these strings can be represented by the regular expression: a*bb*abaaaa*?

  1. aaaabbbbbb
  2. bbbbbbaaaa
  3. aaaabaaaaa
  4. babaaaaaaa

Answer (Detailed Solution Below)

Option 4 : babaaaaaaa

Regular Languages and Finite Automata Question 1 Detailed Solution

The correct answer is Option 4: babaaaaaaa.

Key Points

  • The regular expression a*bb*abaaaa* represents strings that follow these rules:
    • a*: Matches zero or more occurrences of the character 'a'.
    • bb*: Matches one 'b' followed by zero or more occurrences of 'b'.
    • ab: Matches the exact sequence 'ab'.
    • aaaa*: Matches 'aaaa' followed by zero or more occurrences of 'a'.
  • Let's analyze each option:
    • Option 1: aaaabbbbbb - This string does not contain 'ab', so it does not match the regular expression.
    • Option 2: bbbbbbaaaa - This string does not contain 'ab', so it does not match the regular expression.
    • Option 3: aaaabaaaaa - This string does not contain 'ab', so it does not match the regular expression.
    • Option 4: babaaaaaaa - This string matches the regular expression:
      • a*: Matches zero occurrences of 'a'.
      • bb*: Matches one 'b'.
      • ab: Matches the sequence 'ab'.
      • aaaa*: Matches 'aaaa' followed by four 'a's.

Additional Information

  • Regular expressions are used to define patterns for matching strings.
  • They are commonly used in programming for searching, replacing, and validating text.
  • The expression a*bb*abaaaa* ensures a specific sequence of characters while allowing flexibility with repetitions.
  • Understanding the structure of a regular expression is crucial for determining valid matches.

Regular Languages and Finite Automata Question 2:

Consider the finite automata given below :

The language b accepted by this automata is given by the regular expression :

  1. b* a b * a b * a b * 
  2. (a + b)* 
  3. b*a (a + b)*
  4. b* ab* ab*

Answer (Detailed Solution Below)

Option 1 : b* a b * a b * a b * 

Regular Languages and Finite Automata Question 2 Detailed Solution

The correct answer is Option 1: b* a b * a b * a b *.
Key Points
  • The regular expression b* a b * a b * a b * represents the language accepted by the given finite automata.
  • This regular expression can be broken down as follows:
    • b* matches zero or more occurrences of the character 'b'.
    • a matches a single occurrence of the character 'a'.
    • Repeating the pattern b* a three more times ensures that the sequence 'a' appears exactly three times, each possibly preceded by zero or more 'b's.
  • This pattern matches any string of 'b's followed by 'a', and this sequence is repeated three times.
Additional Information
  • The finite automata can be visualized as having states that transition between each other upon reading specific inputs (characters).
  • Understanding the structure of the automata and the transitions helps in deriving the correct regular expression that represents the language it accepts.
  • Finite automata are used in various fields such as text processing, compiler design, and network protocols to recognize patterns and validate input sequences.
  • Regular expressions are a powerful tool for describing patterns in strings and are widely used in search algorithms, text processing, and input validation.

Regular Languages and Finite Automata Question 3:

Comprehension:

A machine is represented by states Q, input alphabet Σ, transition function δ. Initial state qo and final state F. The machine accepts all the strings over Σ = {a,b}, which starts and ended with any combination of all alphabet and abb works/lies in all the strings to be accepted 

Which of the following represented the minimum state DFA for the above specified passage?

Answer (Detailed Solution Below)

Option 1 :

Regular Languages and Finite Automata Question 3 Detailed Solution

The correct answer is : option 1

Key Points

Problem Statement:

We are given four DFAs and must identify the minimum state DFA that accepts the language L, where:

  • Σ = {a, b}
  • L = Set of all strings where "abb" is a substring

This means the DFA should:

  • Accept any string that contains "abb" anywhere in the string
  • Reject strings that do not contain the exact substring "abb"

Designing the DFA for 'abb' recognition:

The DFA must track three progress levels to reach the substring "abb":

  1. q0: Initial state, no match yet
  2. q1: After reading 'a'
  3. q2: After reading 'ab'
  4. q3: After reading 'abb'Final State

After reaching the final state, any number of further characters should be accepted (loop at final state).

Option 1 (Correct):

Let's trace the transitions:

  • q1 (Start) — a → q2
  • q2 — b → q3
  • q3 — b → q4 (final state starts)
  • q4 → loops on a
  • q5 is a trap or accepting completion state

✔ Accepts 'abb' as required and uses minimum 5 states to precisely track substring occurrence. This matches the textbook minimum-state DFA for 'abb'.

❌ Option 2:

  • Only 4 states used
  • Transitions are not correctly capturing the 'abb' sequence
  • No backtracking after false match paths

 Invalid – misses important transition sequences for 'abb'

❌ Option 3:

  • Correct transitions but uses 6 states
  • Matches 'abb' and has extra states for suffix handling

⚠ Valid DFA but not minimum

❌ Option 4:

  • Similar issue as Option 2
  • Does not correctly identify and confirm the full sequence 'abb'
✖ Invalid – lacks necessary state tracking for full substring

 Final Answer: Correct Option: Option 1

This DFA efficiently tracks the substring "abb" with minimal 5 states and is functionally correct and minimal for the language.

Regular Languages and Finite Automata Question 4:

Comprehension:

A machine is represented by states Q, input alphabet Σ, transition function δ. Initial state qo and final state F. The machine accepts all the strings over Σ = {a,b}, which starts and ended with any combination of all alphabet and abb works/lies in all the strings to be accepted 

For the above specified passage, which of the following represent the grammar for the language accepted the machine?

  1. S → AabbB, A → aA|∈, B → bB|∈
  2. S → abbA, A → aA|∈|bA
  3. S → AabbA, A → aA|bA|∈
  4. S → Aabb, A → aA|bA|∈

Answer (Detailed Solution Below)

Option 3 : S → AabbA, A → aA|bA|∈

Regular Languages and Finite Automata Question 4 Detailed Solution

The correct answer is : option 3

Important Points

Question Objective:

We are asked to identify the grammar that correctly represents the language accepted by the machine. From the comprehension, the machine:

  • Accepts all strings over Σ = {a, b}
  • Strings can start and end with any combination
  • Must contain the substring "abb"

Desired Grammar Structure:

We can divide the string into 3 parts to construct the grammar:

  • Prefix: Any combination of 'a' and 'b' — this can be represented using recursion (A → aA | bA | ε)
  • Middle: The fixed substring 'abb'
  • Suffix: Again, any combination of 'a' and 'b' — again can be represented by A

Thus, an ideal grammar looks like:

S → AabbA  
A → aA | bA | ε

Option-wise Evaluation:

✅ Option 3:

S → AabbA
A → aA | bA | ε
  • This grammar allows any string with 'abb' in the middle
  • A before and after 'abb' ensures prefix and suffix can be anything

✅ Correct – matches the requirement precisely

❌ Option 1:

S → AabbB  
A → aA | ε  
B → bB | ε
  • Introduces a separate non-terminal B after 'abb' which is not necessary
  • Creates a possibility that "abb" may not be present if A and B generate empty string

Incorrect – structure deviates from strict placement of 'abb'

❌ Option 2:

S → abbA  
A → aA | ε | bA
  • Prefix flexibility is missing
  • Only strings starting with "abb" will be accepted

Incorrect – does not accept strings with prefix before "abb"

❌ Option 4:

S → Aabb  
A → aA | bA | ε
  • No suffix A after "abb"
  • Only strings ending in "abb" are accepted

Incorrect – fails to allow suffix characters after "abb"

Final AnswerCorrect Option: Option 3

This grammar ensures that "abb" is included in the middle of the string and is surrounded by any number of valid symbols from Σ = {a, b}.

Regular Languages and Finite Automata Question 5:

Comprehension:

A machine is represented by states Q, input alphabet Σ, transition function δ. Initial state qo and final state F. The machine accepts all the strings over Σ = {a,b}, which starts and ended with any combination of all alphabet and abb works/lies in all the strings to be accepted 

For the above mentioned passage which of the following is correct?

Answer (Detailed Solution Below)

Option 3 :

Regular Languages and Finite Automata Question 5 Detailed Solution

The correct answer is : option 3

Key Points

Comprehension RecapThe DFA must recognize strings over Σ = {a, b} that satisfy the following:

  • They may start and end with any combination of 'a' and 'b'.
  • The string must contain the substring 'abb' anywhere within it.

GoalWe want a DFA that detects the presence of 'abb' anywhere, and allows characters before and after it.

Basic Structure of DFA to Accept 'abb':

  • q1: Start state, accepts any number of a or b.
  • q2: Transition on a from q1 (start of "abb").
  • q3: Transition on b from q2 (second symbol).
  • q4: Transition on b from q3 – string "abb" confirmed. This is a final state.
  • q4 loops on both a and b to accept trailing characters.

Option-Wise Analysis:

Option 3 (Correct):

  • q1 loops on a and b – allows any prefix.
  • q1 --a--> q2
  • q2 --b--> q3
  • q3 --b--> q4 (Final State)
  • q4 loops on a and b – accepts suffix after "abb".

✅ This matches the behavior expected: accepts all strings containing "abb" regardless of their prefix or suffix.

 Option 1:

  • Correct prefix handling (q1 loops on a, b).
  • Transitions toward detecting "abb" are correct.
  • However, q4 lacks a loop on a or b.

❌ This DFA accepts only strings ending at 'abb', and fails if more characters follow.

Option 2:

  • q1 does NOT loop on a or b.
  • This means only strings starting with a are accepted.
  • Violates the rule that string can start with any symbol.

❌ Fails to meet the start flexibility requirement.

Option 4:

  • Transitions are not consistent with detecting "abb".
  • q3 returns back to q1 on b, preventing reaching a final state on "abb".

❌ Cannot reach accepting state on any valid 'abb' sequence.

Final Answer: Option 3

This DFA fulfills the language requirements: accepts any string containing 'abb', with any combination of 'a' and 'b' before or after it.

Top Regular Languages and Finite Automata MCQ Objective Questions

Identify the language generated by the following grammar, where S is the start variable.

S → XY

X → aX | a

Y → aYb | ϵ

  1. {ambn | m ≥ n, n > 0}
  2. {ambn | m ≥ n, n ≥ 0}
  3. {ambn | m > n, n ≥ 0}
  4. {ambn | m > n, n > 0}

Answer (Detailed Solution Below)

Option 3 : {ambn | m > n, n ≥ 0}

Regular Languages and Finite Automata Question 6 Detailed Solution

Download Solution PDF

Grammar:

S → XY

X → aX | a

Y → aYb | ϵ

Explanation:

X generates at least one a. Generates a string of type {a, aa, aaa, aaaa……}

ambn, if n = 0 and m = 0 ∴ string = ϵ which cannot be generated from the given grammar and hence option 2 is incorrect.

Y generates an equal number of a and b { ϵ, ab, aabb, ……} with a comes before b.

Since at least one a is generated by X and an equal number of a’s and b’s generated by Y ∴ m> n and hence option 1 is incorrect

The smallest length string generated by Y is ϵ. In ambn, n ≥ 0 and hence option 4 is incorrect.

{ a, aab, aaabb,………….} which is equivalent to :

L = {ambn | m > n, n ≥ 0}

Which of the following languages is generated by the given grammar?

S → aS | bS | ϵ  

  1. {anbm | n, m ≥ 0}
  2. {w ∈ {a, b} * | w has equal number of a’s and b’s}
  3. {an | n ≥ 0} ∪ { bn | n ≥ 0} ∪ {abn | n ≥ 0}
  4. (a + b}*

Answer (Detailed Solution Below)

Option 4 : (a + b}*

Regular Languages and Finite Automata Question 7 Detailed Solution

Download Solution PDF

S → aS | bS | ϵ 

This grammar results in (a + b)*

DFA for this grammar is:

Diagram

Now, consider the options one by one:

Option 1:

{anbm | n, m ≥ 0}

Here order is fixed, means first any number of a will come then any number of b. It is incorrect.

Option 2: 

{w ϵ {a, b} * | w has an equal number of a’s and b’s}

As given grammar is not generating the expression which generates only equal number of a and b. So,

not correct.

Option 3:

{an | n ≥ 0} {bn | n ≥ 0} {anbn | n ≥ 0}

Here, also order is fixed. So, it is incorrect.

Option 4:

{a, b}*

This is equivalent to (a + b)*. So, it is correct.

The minimum possible number of states of a deterministic finite automation that accepts the regular language L = {w1aw2 | w1, w2 ϵ {a, b}*, |w1| = 2, |w2| ≥ 3} is ________.

Answer (Detailed Solution Below) 8

Regular Languages and Finite Automata Question 8 Detailed Solution

Download Solution PDF

Given language is:  L = {w1aw2 | w1, w2 ϵ {a, b}*, |w1| = 2, |w2| ≥ 3}

Regular expression: (a+b) (a+b) a (a+b) (a+b) (a+b)(a+b)*

Minimum length string that is possible = (a+b) (a+b) a (a+b) (a+b) (a+b)

This string has minimum length 6. For these 7 states are needed and one trap state. So, total 8 states are needed.

DFA for given language is

Consider the DFAs M and N given above. The number of states in a minimal DFA that accepts the language L(M) ∩ L(N) is____________________

Answer (Detailed Solution Below) 1

Regular Languages and Finite Automata Question 9 Detailed Solution

Download Solution PDF

Consider DFA M,

It is accepting all the string that ends with a.

Language for DFA M L(M) = {a, aa, ba, aaa, aba, …}

Regular expression = (a + b )*a

DFA N is accepting all the languages ending with b.

Language for DFA N L (n) = {b, ab, bb, aab, abb, bbb,…….}

Regular expression = (a + b)*b

Intersection of both these languages L (M) ꓵ L(N) = { } = Ø i.e. empty language

For this, we just need 1 state with all transitions to itself and no final state.

Language L1 is defined by the grammar: S1 → aS1b|ϵ

Language L2 is defined by the grammar: S2 → abS2

Consider the following statements:

P: L1 is regular

Q: L2 is regular

Which one of the following is TRUE?

  1. Both P and Q are true
  2. P is true and Q is false
  3. P is false and Q is true
  4. Both P and Q are false

Answer (Detailed Solution Below)

Option 3 : P is false and Q is true

Regular Languages and Finite Automata Question 10 Detailed Solution

Download Solution PDF

Suppose grammar G1:

S1 → aS1b|ϵ

It generates language in which number of a’s are equal to number of b’s and all a’s are followed by b’s

L1 = { an bn | n ≥ 0}.

It is deterministic context free language. Extra memory is required for this. So, it can’t be accepted by finite state automata. L1 is not a regular language.

Now, another grammar let G2: S2 → abS2

This grammar also generates language in which number of a’s are equal to number of b’s. But it generates language L2 = { (ab)n | n ≥ 0 }

Regular expression for this = (ab)*

It doesn’t require any extra memory to remember the last string. It can be accepted by finite state automata. So, L2 is regular.

If L is a regular language over Σ = {a, b}, which one of the following languages is NOT regular?

  1. L . LR = {xy | x ϵ L, yR ϵ L}
  2. {wwR | w ϵ L}
  3. Prefix (L) = {x ϵ ∑* | ∃x ϵ ∑* such that xy ϵ L}
  4. Suffix (L) = {y ϵ ∑* | ∃x ϵ ∑* such that xy ϵ L}

Answer (Detailed Solution Below)

Option 2 : {wwR | w ϵ L}

Regular Languages and Finite Automata Question 11 Detailed Solution

Download Solution PDF
  • Non-deterministic push down automata (NPDA) determines the middle position of the string in the language and start popping until Z(end of stack elements) is meet to tell the acceptance of it .
  • As all the string present in the language wwR accepted by NPDA Hence it is a context free language (CFL).
  • From the properties of regular language: Reverse, Suffix, Prefix, Concatenation of Regular language is Regular.
  • Every regular language is context free language, but every context free language is not a regular language also wwR it is not possible to give, DFA, NFA or ϵ - NFA accepting the language. Therefore, it is not Regular language.

Consider the language L given by the regular expression (a + b)* b (a + b) over the alphabet {a, b}. The smallest number of states needed in a deterministic finite-state automaton (DFA) accepting L is ________.

Answer (Detailed Solution Below) 4

Regular Languages and Finite Automata Question 12 Detailed Solution

Download Solution PDF

Concept:

First convert the given regular expression into an NFA and then find out the DFA from NFA.

Explanation: 

Regular expression is (a + b) * b (a + b)

NFA for this expression is given here as:

Diagram: NFA

NFA Table:

States

a

b

→ q0

q0

{q0, q1}

q1

q2

q2

q2

ϕ

ϕ

 

DFA Table from the above NFA

States

a

b

→ q0

q0

{q0, q1}

{q0, q1}

{q0, q2}

{q0, q1, q2}

*{q0, q2}

q0

{q0, q1}

*{q0, q1, q2}

{q0, q2}

{q0, q1, q2}

 

Diagram: DFA

This DFA can’t be minimized further. So, for the given regular expression minimum number of states in the DFA is 4.

Let δ denote the transition function and  denote the extended transition function of the ϵ-NFA whose transition table is given below:

δ

ϵ

a

b

→ q0

{q2}

{q1}

{q0}

q1

{q2}

{q2}

{q3}

q2

{q0}

ϕ

ϕ

*q3

ϕ

ϕ

{q2}

 

Then  is

  1. ϕ
  2. {q0, q1, q3}
  3. {q0, q1, q2}
  4. {q0, q2, q3}

Answer (Detailed Solution Below)

Option 3 : {q0, q1, q2}

Regular Languages and Finite Automata Question 13 Detailed Solution

Download Solution PDF

Concept:

Extended transition function means when we start from a state and follow a sequence of input.

In case of ϵ-NFA, epsilon moves are also considered.

Diagram: NFA for the given NFA table is:

Here,  

Explanation:

When input a is applied on q2 it will move to q0, q1 as there is null transition so it will also get to q2.

Similarly, states after input b => {q0, q2, q3}

States after input a = {q0, q1, q2}

So, final answer is {q0, q1, q2}

Consider the following statements.

I. If L1 ∪ L2 is regular, then both L1 and L2 must be regular.

II. The class of regular languages is closed under infinite union.

Which of the above statements is/are TRUE?

  1. I only
  2. II only
  3. Both I and II
  4. Neither I nor II

Answer (Detailed Solution Below)

Option 4 : Neither I nor II

Regular Languages and Finite Automata Question 14 Detailed Solution

Download Solution PDF

Statement I: FALSE

If L1 ∪ L2 is regular, then neither L1 nor L2 needs necessarily be regular.

Example:

Assume L1= {an bn, n ≥ 0} over the alphabet {a, b} and L2 be the complement of L1.

Neither L1 nor L2 is regular (both are DCFL) but L1 ∪ L2= {an bn} ∪ {an bn}c = (a + b)* is regular.

Statement II: FALSE. The infinite Union of regular languages is not regular.

Example:

Given alphabet {a, b}.

L1= {ε}

L2= {ab}

L3= {aabb}

L4= {aaabbb}

:

:

L = L1 ∪ L2 ∪ L3 ∪ L4

Each of the above are regular but their infinite Union gives L1= {an bn, n ≥ 0} which is not regular but DCFL.

Note:

DCFL → Deterministic context free language

For Σ = {a, b}, let us consider the regular language L = {x|x = a2+3k or x = b10+12k k ≥ 0}.

Which one of the following can be a pumping length (the constant guaranteed by the pumping lemma) for L?

  1. 3
  2. 5
  3. 9
  4. 24

Answer (Detailed Solution Below)

Option 4 : 24

Regular Languages and Finite Automata Question 15 Detailed Solution

Download Solution PDF

Regular language L = {x|x = a2+3k or x = b10+12k k ≥ 0}.

L = {a2, a5, a8, a11 … ∪ b10, b22, b34…}

Pumping Lemma:

Let L be an infinite regular language. Then there exists some positive integer m such that any w ϵ L with |w|≥ m can be decomposed as

w = xyz

with |xy|≤ m such that wi = xyiz

is also L for all i = 0, 1, 2, …

Therefore, minimum Pumping Length should be 11, because string with length 10 (i.e., w = b10) does not repeat anything, but string with length 11 (i.e., w = b11) will repeat states.

Hence option 1, 2, and 3 are eliminated.

Therefore 24 can be the pumping lemma length.

Hot Links: teen patti palace teen patti customer care number teen patti winner teen patti club