GATE Papers >> CSE >> 2016 >> Question No 156

Question No. 156 CSE | GATE 2016

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
$D\rightarrow\mathbf{int}\boldsymbol\;L;$ $D\boldsymbol\rightarrow\mathbf{int}\boldsymbol\;L;$
$L\rightarrow\mathbf{id}\lbrack E$ $L\boldsymbol\rightarrow\mathbf{id}\boldsymbol\;E$
$E\rightarrow\mathbf{num}\rbrack$ $E\rightarrow E\lbrack\mathbf{num}\rbrack$
$E\rightarrow\mathbf{num}\rbrack\lbrack E$ $E\rightarrow\lbrack\mathbf{num}\rbrack$

 

Which of the grammars correctly generate the declaration mentioned above?

Answer : (A) Both G1 and G2


Solution of Question No 156 of GATE 2016 CSE Paper

Both G1 and G2 can generate int a[10][3];

as follows:

G1:  D → int L; int id[E ;

        →  int id [ num][ E;

        →  int id [num] [num];

G2:  D → int L ;  →  int id E;

                            →  int id E [num];

                            →  int id [num][num];

Comments
ckrLfq http://pills2sale.com/ levitra nizagara

Posted on  18/10/2020 15:37:53  by  dobsonz
nviNIs http://pills2sale.com/ levitra nizagara

Posted on  18/10/2020 15:39:42  by  dobsonz
47xOvn http://pills2sale.com/ viagra cialis buy

Posted on  01/11/2020 20:27:14  by  johnanx
xot8p4 https://www.quora.com/What-the-top-SEO-keywords-for-essay-you-know/answer/Alan-Smith-1772 write my essay

Posted on  04/12/2020 01:41:48  by  dobson
JF3bzE https://www.quora.com/What-the-top-SEO-keywords-for-essay-you-know/answer/Alan-Smith-1772 write my essay

Posted on  04/12/2020 03:02:52  by  dobson
jfm7eO http://xnxx.in.net/ xnxx videos

Posted on  12/12/2020 20:10:42  by  johnan
rCRlHR http://xnxx.in.net/ xnxx videos

Posted on  12/12/2020 21:45:41  by  johnan
faDdVm https://writemyessayforme.web.fc2.com/

Posted on  13/12/2020 04:18:48  by  dobson
ost2nC https://writemyessayforme.web.fc2.com/

Posted on  13/12/2020 04:59:10  by  dobson
SUm2dz https://writemyessayforme.web.fc2.com/#writemyessay

Posted on  15/12/2020 05:18:39  by  dobson
tjNBgr https://writemyessayforme.web.fc2.com/#writemyessay

Posted on  15/12/2020 05:59:06  by  dobson
Oq4Ace https://writemyessayforme.web.fc2.com/octavio-paz-essay-day-of-the-dead.html

Posted on  09/01/2021 10:32:03  by  dobson
TQ2dsY https://writemyessayforme.web.fc2.com/octavio-paz-essay-day-of-the-dead.html

Posted on  09/01/2021 11:34:01  by  dobson
Y5DGzh http://waldorfdollshop.us/ waldorf doll

Posted on  09/01/2021 14:48:38  by  johnanz
JWFZjX http://waldorfdollshop.us/ waldorf doll

Posted on  09/01/2021 15:53:10  by  johnanz
Leave a comment