All Exams Test series for 1 year @ ₹349 only
Question

The context free grammar for the language \(L = \{a^{n}b^{m}c^{k} \mid k = |n - m|, n \geq 0, m \geq 0, k \geq 0\}\) is

This question was previously asked in
UGC NET 2014 Paper 1 Question Paper (28-Dec-2014)
The correct answer is

\(S \rightarrow S_{1} \mid S_{3}, S_{1} \rightarrow aS_{1}c \mid S_{2} \mid \lambda, S_{2} \rightarrow aS_{2}b \mid \lambda, S_{3} \rightarrow aS_{3}b \mid S_{4} \mid \lambda, S_{4} \rightarrow bS_{4}c \mid \lambda\)

Split the language into two cases depending on whether \(n \geq m\) or \(m \geq n\).

If \(n \geq m\), the string is \(a^{n-m}(a^{m}b^{m})c^{n-m}\), generated by \(S_{1} \rightarrow aS_{1}c \mid S_{2}\) with \(S_{2} \rightarrow aS_{2}b \mid \lambda\).

If \(m \geq n\), the string is \((a^{n}b^{n})b^{m-n}c^{m-n}\), generated by \(S_{3} \rightarrow aS_{3}b \mid S_{4}\) with \(S_{4} \rightarrow bS_{4}c \mid \lambda\).

The two cases are alternatives, so the start rule must be \(S \rightarrow S_{1} \mid S_{3}\); concatenating \(S_{1}S_{3}\) would allow extra symbols, and the other grammars use wrong rules for \(S_{1}\).

Hence, \(S \rightarrow S_{1} \mid S_{3}, S_{1} \rightarrow aS_{1}c \mid S_{2} \mid \lambda, S_{2} \rightarrow aS_{2}b \mid \lambda, S_{3} \rightarrow aS_{3}b \mid S_{4} \mid \lambda, S_{4} \rightarrow bS_{4}c \mid \lambda\).

Was this answer helpful?

Similar Questions

  1. The following Context-Free Grammar (CFG) :

    S → aB | bA

    A → a | as | bAA

    B → b | bs | aBB

    will generate

  2. The context free grammar given by

    \(S \to XYX\)

    \(X \to aX \mid bX \mid \lambda\)

    \(Y \to bbb\)

    generates the language which is defined by regular expression :

  3. A context free grammar for \(L = \{ w \mid n_{0}(w) \gt n_{1}(w) \}\) is given by :

  4. If all the production rules have single non - terminal symbol on the left side, the grammar defined is :

  5. Match the following :

    List - IList - II
    a. Chomsky Normal formi. \(S \to b\,S\,S \mid a\,S \mid c\)
    b. Greibach Normal formii. \(S \to a\,S\,b \mid ab\)
    c. S-grammariii. \(S \to AS \mid a\)
    \(A \to SA \mid b\)
    d. LL grammariv. \(S \to a\,B\,S\,B\)
    \(B \to b\)
  6. For the above specified passage, which of the following represent the grammar for the language accepted the machine?

  7. Which of the folowing CFG(s) is/are in chomsky Normal form (All capital letters are variables & lower case are terminals)

    A. S → ABC / AB
    A → a
    B → b
    C → d

    B. X → RT / TR
    T → t
    R → XT / r

    C. P → qP / sQ
    Q → r / s

    D. M → MN / MP
    N → nm / n
    P → p

    Choose the correct answer from the options given below:

  8. Let G = (V, T, S, P) be a context-free grammar such that every one of its productions is of the form A → v, with |v| = K > 1. The derivation tree for any W ∈ L(G) has a height h such that


Important Questions from Context Free Grammars

  1. Which of the following Grammars is/are only Context Free?
    AS $\rightarrow$ Ab
    aS$\rightarrow$ aA
    A$\rightarrow$ a
    BS $\rightarrow$ Ab
    A $\rightarrow$ Sa
    A $\rightarrow$ a
    CS $\rightarrow$ AS
    S $\rightarrow$ aA
    A$\rightarrow$ a
    DS $\rightarrow$ Ab
    S $\rightarrow$ aA
    A$\rightarrow$ a
    ES $\rightarrow$ Sb
    A $\rightarrow$ Aa
    A $\rightarrow$ $\varepsilon$

    Choose the correct answer from the options given below:
  2. Which of the following grammars is (are)ambiguous ?
    (1) S → SS | aSb | bSa |e 

    (2) S → aSbS | bSaS |e 

    (3) S → aAB 

    A → bBb 
    B → A Ι e

  3. Consider the grammar,

    G = S → abScB | e, 

    B→ bB | b. 

    What is the language generated by the given grammar ?

     

  4. Consider the given grammar
    S → Abc | ad 

    A → eS | Cr| ξ 

    C → f/p/ξ
    Compute FIRST (A)

  5. Select the sentence which is meaningful and grammatically correct.

Need Expert Advice?
Upcoming Exams
CTET
December 12, 2026
CBSE UGC NET
December 14, 2026
CSIR UGC NET
December 19, 2026
Test Series
UGC NET img
Teaching
UGC NET (Paper 2) 2026 Mock Test Series
796 Tests 2 Tests Free
4.4(40)
English
More Questions from UGC NET

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App