Home » Theory of Computation » Theory of computation miscellaneous » Question

Theory of computation miscellaneous

Theory of Computation

  1. Consider the following grammar G :
    S → bS|aA|b
    A → bA |aB
    B → bB|aS| a
    Let Na (W) and Nb (W) denote the number of a 's and b 's in a string W respectively.
    The language L(G) ⊆ {a, b}+ generated by G is
    1. {W|Na (W) > 3Nb (W)}
    2. {W|Nb (W) > 3Na (W)}
    3. {W|Na (W) = 3k, k ∈ {0, 1, 2,...}}
    4. {W|Nb (W) = 3k, k ∈ {0, 1, 2,...}}
Correct Option: C

Here, we have
S → bS
S → baA (S → aA)
S → baaB (A → aB)
S → baaa (B → a)
Therefore, | Na (w) | = 3.
Also, if we use A → bA instead of A → aB,
S → baA
S → babA
To terminate A, we would have to use A→ aB as only B terminates at a (B → a).
S → baA
S → babA
S → babaB
S → babaa
Thus, here also, | Na (w) | = 3. So, C is the correct answer.



Your comments will be displayed only after manual approval.