Which of the above strings are generated by the grammer?
A
(iii) and (iv)
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
B
(i), (iii) and (iv)
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
(i), (ii) and (iii)
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
(ii), (v) and (vi)
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution
The correct option is A (iii) and (iv) This grammer cannot generate any string starting with xx or ending with xx so (i), (ii) and (v) cannot be generated by the grammer. xyx also cannot be generated by the grammer. The derivation for (iii) xyxy and (iv) yxxy is shown below
S→xB→xyS→xyxB→xyxy
S→yA→yxS→yxxS→yxxy
So only (iii) and (iv) can we derived from this grammer.