1
GATE CSE 2005
MCQ (Single Correct Answer)
+2
-0.6

Consider the following expression grammar. The seman­tic rules for expression calculation are stated next to each grammar production.

$$\eqalign{ & E \to number\,\,\,\,\,E.val = number.val \cr & \,\,\,\,\,\,\,\,\,\,\,|E\,\,' + '\,\,E\,\,\,\,\,\,{E^{\left( 1 \right)}}.val = {E^{\left( 2 \right)}}.val + {E^{\left( 3 \right)}}.val \cr & \,\,\,\,\,\,\,\,\,\,\,|\,E\,\,' \times '\,\,E\,\,\,\,\,\,\,{E^{\left( 1 \right)}}.val = {E^{\left( 2 \right)}}.val \times {E^{\left( 3 \right)}}.val \cr} $$

The above grammar and the semantic rules are fed to a yacc tool (which is an LALR (1) parser generator) for parsing and evaluating arithmetic expressions. Which one of the following is true about the action of yacc for the given grammar?

A
It detects recursion and eliminates recursion
B
It detects reduce-reduce conflict, and resolves
C
It detects shift-reduce conflict, and resolves the conflict in favor of a shift over a reduce action
D
It detects shift-reduce conflict, and resolves the conflict in favor of a reduce over a shift action
2
GATE CSE 2005
MCQ (Single Correct Answer)
+2
-0.6

Consider the following expression grammar. The seman­tic rules for expression calculation are stated next to each grammar production.

$$\eqalign{ & E \to number\,\,\,\,\,E.val = number.val \cr & \,\,\,\,\,\,\,\,\,\,\,|E\,\,' + '\,\,E\,\,\,\,\,\,{E^{\left( 1 \right)}}.val = {E^{\left( 2 \right)}}.val + {E^{\left( 3 \right)}}.val \cr & \,\,\,\,\,\,\,\,\,\,\,|\,E\,\,' \times '\,\,E\,\,\,\,\,\,\,{E^{\left( 1 \right)}}.val = {E^{\left( 2 \right)}}.val \times {E^{\left( 3 \right)}}.val \cr} $$

Assume the conflicts in the previous question are resolved and an LALR(1) parser is generated for parsing arithmetic expressions as per the given grammar. Consider an expression
3 × 2 + 1.
What precedence and associativity properties does the generated parser realize?

A
Equal precedence and left associativity; ex­pression is evaluated to 7
B
Equal precedence and right associativity; ex­pression is evaluated to 9
C
Precedence of $$' \times '$$ is higher than that of ‘+’, and both operators are left associative; expression is evaluated to 7
D
Precedence of ‘+’ is higher than that of $$' \times '$$, and both operators are left associative; expression is evaluated to 9
3
GATE CSE 2005
MCQ (Single Correct Answer)
+2
-0.6
Consider line number 3 of the following C - program.
int main ( ) {              /* Line 1 */ 
int I, N;                   /* Line 2 */ 
fro (I = 0, I < N, I++);    /* Line 3 */ 
} 
Identify the compiler's response about this line while creating the object-module
A
No compilation error
B
Only a lexical error
C
Only syntactic errors
D
Both lexical and syntactic errors
4
GATE CSE 2005
MCQ (Single Correct Answer)
+1
-0.3
In a network of LANs connected by bridges, packets are sent from one LAN to another through intermediate bridges. Since more than one path may exist between two LANs, packets may have to be routed through multiple bridges. Why is the spanning tree algorithm used for bridge-routing?
A
For shortest path routing between LANs
B
For avoiding loops in the routing paths
C
For fault tolerance
D
For minimizing collisions
EXAM MAP
Medical
NEET
Graduate Aptitude Test in Engineering
GATE CSEGATE ECEGATE EEGATE MEGATE CEGATE PIGATE IN
CBSE
Class 12