MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

THEORY OF COMPUTATION

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Following context free grammarS-> aB | bA A->b | aS | bAAB-> b | bS | aBB generates strings of terminals that have
A
equal number of a’s and b’s
B
odd number of a’s and odd number b’s
C
even number of a’s and even number of b’s
D
odd number of a’s and even number of a’s
Explanation: 

Detailed explanation-1: -A language generated by a CFG is a context-free language (CFL).

Detailed explanation-2: -Context free grammar is a formal grammar which is used to generate all possible strings in a given formal language. Context free grammar G can be defined by four tuples as: G= (V, T, P, S)

Detailed explanation-3: -Definition (Context-Free Grammar) : A 4-tuple G = < V, , S, P > is a context-free grammar (CFG) if V and are finite sets sharing no elements between them, S V is the start symbol, and P is a finite set of productions of the form X->, where X V, and ( V )* .

Detailed explanation-4: -We derive strings in the language of a CFG by starting with the start symbol, and repeatedly replacing some variable A by the right side of one of its productions. That is, the “productions for A” are those that have A on the left side of the->. We say A => if A-> is a production. Example: S-> 01; S-> 0S1.

There is 1 question to complete.