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

Last updated on Apr 8, 2025

Latest Regular Languages MCQ Objective Questions

Regular Languages Question 1:

Consider the finite automata given below :

qImage67c1630a35ecce8b26c10db4

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 Question 1 Detailed Solution

The correct answer is Option 1: b* a b * a b * a b *.

key-point-image 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-image 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 Question 2:

Which of the following is TRUE about the Pumping Lemma for regular language?

  1. It applies to all regular language
  2. It applies only to infinite regular languages
  3. It applies to all context - free languages
  4. It applies to all recursively enumerable languages

Answer (Detailed Solution Below)

Option 1 : It applies to all regular language

Regular Languages Question 2 Detailed Solution

The correct answer is It applies to all regular languages.

Key Points

  • The Pumping Lemma is a property that applies to all regular languages, and it is used to prove whether a language is not regular.
    • If a language is regular, there exists some length (p) such that any string longer than p can be divided into three parts, xyz, satisfying certain conditions.
    • The conditions are: for the string xyz, the length of xy is at most p, y is not an empty string, and the string xy^iz (i ≥ 0) is still in the language.
    • The Pumping Lemma helps in identifying strings that cannot be pumped, thereby proving that the language is not regular.

Additional Information

  • The Pumping Lemma does not apply to finite languages, as there is no need to pump strings in such cases.
  • While the Pumping Lemma provides a necessary condition for regularity, it is not a sufficient condition; that is, some non-regular languages may satisfy the lemma.
  • The lemma is a fundamental concept in the theory of computation and automata theory, helping in understanding the limitations of regular languages.
  • It is an essential tool in formal language theory for distinguishing between regular and non-regular languages.

Regular Languages Question 3:

 Consider the languages L1= \(\phi\) and L2={a}. Which of the following represents L1 L2* U L1* ? 

  1. {\(\sigma\)
  2. {\(\varepsilon\phi\)
  3. {\(\pi\)
  4. {\(\varepsilon\)

Answer (Detailed Solution Below)

Option 4 : {\(\varepsilon\)

Regular Languages Question 3 Detailed Solution

The correct answer is {\(\varepsilon\)

Concepts

\({{\rm{L}}^{\rm{*}}} = {{\rm{L}}^0} \cup {{\rm{L}}^1} \cup {{\rm{L}}^2} \cup {{\rm{L}}^3} \cup {{\rm{L}}^4} \ldots \ldots .{{\rm{L}}^{\rm{k}}} \cup {{\rm{L}}^{{\rm{k}} + 1}} \ldots \ldots \ldots \)

For any language \({{\rm{L}}^0} = \epsilon\)

Concatenation of \({\rm{\Phi }}\) with any other language is \({\rm{\Phi }}\). It works as 0 in multiplication.

And for \({{\rm{L}}^{\rm{k}}} = {\rm{L}}.{\rm{L}}.{\rm{L}}.{\rm{L}}.{\rm{L}}.{\rm{L}}.{\rm{L}} \ldots \ldots \ldots {\rm{\;L}}\) language is concatenated K- times.

Data:

 L1 = Φ, L2 = {a}

Calculation:

\({L_1}L_2^* \cup L_1^* = \;?\)

\({{\rm{L}}_1}\) concatenated with \(L_2^*\) and whole thing union with \(L_1^*\).

First \({\rm{\;L}}_1^{\rm{*}} = {\rm{\;\;}}{\phi ^0} \cup {\phi ^1} \cup {\phi ^2} \ldots \ldots {\rm{\;}}\)  \(= \epsilon \cup \phi \cup \phi \ldots \ldots = \left\{ \epsilon \right\}.\)

Similarly, \({\rm{L}}_2^{\rm{*}} = {\left\{ {\rm{a}} \right\}^0} \cup {\left\{ {\rm{a}} \right\}^1} \cup {\left\{ {\rm{a}} \right\}^2} \ldots \ldots {\rm{\;}} = \epsilon \cup \left\{ {\rm{a}} \right\} \cup \left\{ {{\rm{aa}}} \right\} \ldots \ldots .. = {{\rm{a}}^{\rm{*}}}\)

\({{\rm{L}}_1}{\rm{L}}_2^{\rm{*}} \cup {\rm{L}}_1^{\rm{*}} = {\rm{\Phi \;}}{{\rm{a}}^{\rm{*}}} \cup \left\{ \epsilon \right\} = \left\{ \epsilon \right\}\)

Regular Languages Question 4:

What is the pumping length of string of length x? 

  1. x+1 
  2. x
  3. x-1
  4. x2

Answer (Detailed Solution Below)

Option 1 : x+1 

Regular Languages Question 4 Detailed Solution

The correct answer is x+1

Key Points

  • The pumping length needs to be greater than the length of the string itself (x) to guarantee the existence of two separate substrings (x and y).
  • These two substrings should have a combined minimum length that exceeds p.
  • This minimum combined length (x + 1) then becomes the pumping length (p).

Therefore, the correct option is C. (x + 1).

Regular Languages Question 5:

If L1 and L2 are context free languages, which of the following is True about L1 ∩ L?

  1. L1 ∩ L2 is context free
  2. L1 ∩ Lis Regular
  3. L1 ∩ Lis Recursively Enumerable
  4. L1 ∩ Lis Context Sensitive

Answer (Detailed Solution Below)

Option 3 : L1 ∩ Lis Recursively Enumerable

Regular Languages Question 5 Detailed Solution

The correct answer is L1 ∩ Lis Recursively Enumerable

Concept:

To determine the properties of the intersection of two context free languages L1 and L2 , we need to analyze each option provided.

Context-Free Languages

1. L1 and L2 are Context-Free Languages (CFLs): 
    Context-free languages are closed under union and concatenation but not closed under intersection.

Explanation:

1. L1 ∩ L2 is context-free:  
    False. The intersection of two context-free languages is not guaranteed to be context free. For example, if \(L_1 = \{ a^n b^n | n \geq 0 \} and L_2 = \{ b^n c^n | n \geq 0 \} , then L_1 \cap L_2 = \{ b^n | n \geq 0 \}\) , which is not context-free in this context.

2. L1 ∩ L2 is regular:  
    False. The intersection of two context-free languages is not necessarily regular. Regular languages are a subset of context free languages, but the intersection of two CFLs can produce a language that is not regular.

3. L1 ∩ L2 is recursively enumerable:  
    True. Context-free languages are a subset of recursively enumerable languages. Since both L1 and L2 are context-free, their intersection L1 ∩ L2 is recursively enumerable.

4. L1 ∩ L2 is context-sensitive:  
    True, but it is a broader statement. All context-free languages are context-sensitive, and since the intersection can produce a language that fits within the context-sensitive category, this statement is also valid, but it doesn't specifically apply only to CFLs.

Conclusion: The correct answer is: 3) L1 ∩ L2 is Recursively Enumerable

Top Regular Languages 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 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 Question 7 Detailed Solution

Download Solution PDF

S → aS | bS | ϵ 

This grammar results in (a + b)*

DFA for this grammar is:

Diagram

F2 R.S Madhu 17.12.19 D2

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.

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 Question 8 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 Question 9 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 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 Question 10 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 Question 11 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.

Which one of the following regular expressions represents the language: the set of all binary strings having two consecutive 0s and two consecutive 1s? 

  1. (0 + 1) *0011 (0 + 1)* + (0 + 1) *1100 (0 + 1)*
  2. (0 + 1) *(00(0 + 1)*11 + 11 (0 + 1)*00) (0 + 1)*
  3. (0 + 1) *00 (0 + 1)* + (0 + 1) *11 (0 + 1)*
  4. 00 (0 + 1) *11 + 11 (0 + 1) *00

Answer (Detailed Solution Below)

Option 2 : (0 + 1) *(00(0 + 1)*11 + 11 (0 + 1)*00) (0 + 1)*

Regular Languages Question 12 Detailed Solution

Download Solution PDF

Consider all the options one by one:

1) (0 + 1) *0011 (0 + 1)* + (0 + 1) *1100 (0 + 1)*

It consider only those string which have either 0011 or 1100 as a substring. So, it is wrong.

2) (0 + 1) *(00(0 + 1)*11 + 11 (0 + 1)*00) (0 + 1)*

It contains set of all the binary strings that contain two consecutive 0’s and 1’s.

3) (0 + 1) *00 (0 + 1)* + (0 + 1) *11 (0 + 1)*

This set contains only those string which have either 00 or 11 as substring but not does not contain all the strings that contain two consecutive 0’s and 1’s.

4) 00 (0 + 1) *11 + 11 (0 + 1) *00

It represents those strings which start with 00 or 11 and end with 11 or 00 respectively. So, it is wrong.

Match the following:

P. Lexical analysis

1. Graph coloring

Q. Parsing

2. DFA minimization

R. Register allocation

3. Post-order traversal

S. Expression evaluation

4. Production tree

  1. P – 2, Q – 3, R – 1, S - 4
  2. P – 2, Q – 1, R – 4, S - 3
  3. P – 2, Q – 4, R – 1, S - 3
  4. P – 2, Q – 3, R – 4, S - 1

Answer (Detailed Solution Below)

Option 3 : P – 2, Q – 4, R – 1, S - 3

Regular Languages Question 13 Detailed Solution

Download Solution PDF

Lexical analysis: Lexical analysis is the first phase of compiler also known as scanner. It converts the high-level input program into a sequence of tokens. Lexical analysis can be implemented by deterministic finite automata.

Parsing: Parser constructs a production tree. Parse tree is a hierarchical structure which represents the derivation of the programmer to yield input strings.

Register allocation: Register allocation reduces to graph coloring problem in which colors (registers) are assigned to the nodes such that two nodes connected by an edge do not receive the same color.

Expression evaluation: Expression evaluation is done using post order traversal.

Pumping lemma for regular language is generally used for proving :

  1. whether two given regular expressions are equivalent
  2. a given grammar is ambiguous
  3. a given grammar is regular
  4. a given grammar is not regular

Answer (Detailed Solution Below)

Option 4 : a given grammar is not regular

Regular Languages Question 14 Detailed Solution

Download Solution PDF

The correct answer is option 4.

Key Points

The pumping lemma is often used to prove that a particular language is non-regular. Pumping lemma for regular language is generally used for proving a given grammar is not regular.

Hence the correct answer is a given grammar is not regular.

Additional Information

Pumping Lemma is to be applied to show that certain languages are not regular. It should never be used to show a language is regular.

If L is regular, it satisfies Pumping Lemma.

If L does not satisfy Pumping Lemma, it is non-regular.

Which one of the following regular expressions represents the set of all binary strings with an odd number of 1’s?

  1. ((0 + 1)*1(0 + 1)*1)*10*
  2. (0*10*10*)*0*1
  3. 10*(0*10*10*)*
  4. 0*(10*10*)*10*

Answer (Detailed Solution Below)

Option 4 : 0*(10*10*)*10*

Regular Languages Question 15 Detailed Solution

Download Solution PDF

Concept:

The regular expression should generate all possible binary strings with odd number of 1’s and doesn’t generate the other strings.

Option 1: Incorrect

Regular Expression: ((0 + 1)*1(0 + 1)*1)*10*

String: 11110

It can generate strings (11110) with even number of 1’s also

Option 2: Incorrect

Regular Expression: (0*10*10*)*0*1

It will generate string only ending with ‘1’

String: 1110

It cannot generate ‘1110’ substring.

Option 3: Incorrect

Regular Expression: 10*(0*10*10*)*

It will generate string only starting with ‘1’

String: 0111

It cannot generate ‘0111’ substring.

Option 4: Correct

Regular expression: 0*(10*10*)*10*

It will generate all possible binary strings with odd number of 1’s and doesn’t generate the other strings.

Note:

Option 4 has been changed, since none of the option is was correct in official GATE CS 2020 paper

Marks has been given to all.
Get Free Access Now
Hot Links: lucky teen patti teen patti cash teen patti club