GATE : Computer Science and IT

A student wrote two context-free grammars G1 and G2 for generating a single C-like array declaration. The dimension of the array is at least one. For example,
int a[10][3];
The grammars use D as the start symbol, and use six terminal symbols int ; id [ ] num.
Grammar G1




Grammar G2




Which of the grammars correctly generate the declaration mentioned above? a single C-like array declaration. The dimension of the array is at least one. For example,

,

A student wrote two context-free grammars G1 and G2 for generating a single C-like array declaration. The dimension of the array is at least one. For example,
int a[10][3];
The grammars use D as the start symbol, and use six terminal symbols int ; id [ ] num.
Grammar G1




Grammar G2




Which of the grammars correctly generate the declaration mentioned above? a single C-like array declaration. The dimension of the array is at least one. For example,

A student wrote two context-free grammars G1 and G2 for generating a single C-like array declaration. The dimension of the array is at least one. For example,
int a[10][3];
The grammars use D as the start symbol, and use six terminal symbols int ; id [ ] num.
Grammar G1




Grammar G2




Which of the grammars correctly generate the declaration mentioned above? a single C-like array declaration. The dimension of the array is at least one. For example,





Solution
A. Both G1 and G2



Explanation
Both G1 & G2 generates the string: int a[10] [3]; You may use LMD, RMD or parse tree to derive the string.
CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Exam Quiz Website development Company in Allahabad