All mock tests are FREE till 31 December — register to save your progress
Unit 8 · Theory of Computation and Compilers Paper 2 CS · December 2022 Shift 2

Match the following based on the lengths of strings in the language accepted (using the brute-force method of parsing).
Choose the correct answer from the options given below:
List IList II
a. S → aSa | aaI. ((2n × 3) − 4); n ≥ 1
b. S → aaSaa | aaII. 2n; n ≥ 1
c. S → aaaSaaa | aaIII. ((4 × 2n) − 6); n ≥ 1
d. S → aaaaSaaaa | aaIV. 2n − 2; n ≥ 2

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: B. a-II, b-IV, c-I, d-III

Explanation

Lengths: a gives 2, 4, 6, … = 2n (II); c gives 2, 8, 14, … = 6n − 4 (I); d gives 2, 10, 18, … = 8n − 6 (III); b (2, 6, 10, …) takes the remaining IV. Read the List II expressions with 2n as a product.

More Theory of Computation and Compilers questions