Question 1 |

Consider the following augmented grammar with \{ \#, @, <, >, a, b, c \} as the set of terminals.

\begin{array}{l} S' \rightarrow S \\ S \rightarrow S \# cS \\ S \rightarrow SS \\ S \rightarrow S @ \\ S \rightarrow < S > \\ S \rightarrow a \\ S \rightarrow b \\ S \rightarrow c \end{array}

Let I_0 = \text{CLOSURE}(\{S' \rightarrow \bullet S\}). The number of items in the set \text{GOTO(GOTO}(I_0 \lt ), \lt ) is ___________

\begin{array}{l} S' \rightarrow S \\ S \rightarrow S \# cS \\ S \rightarrow SS \\ S \rightarrow S @ \\ S \rightarrow < S > \\ S \rightarrow a \\ S \rightarrow b \\ S \rightarrow c \end{array}

Let I_0 = \text{CLOSURE}(\{S' \rightarrow \bullet S\}). The number of items in the set \text{GOTO(GOTO}(I_0 \lt ), \lt ) is ___________

6 | |

7 | |

8 | |

9 |

Question 1 Explanation:

Question 2 |

Consider the following C code segment:

a = b + c;

e = a + 1;

d = b + c;

f = d + 1;

g = e + f;

In a compiler, this code segment is represented internally as a directed acyclic graph (DAG). The number of nodes in the DAG is _____________

a = b + c;

e = a + 1;

d = b + c;

f = d + 1;

g = e + f;

In a compiler, this code segment is represented internally as a directed acyclic graph (DAG). The number of nodes in the DAG is _____________

11 | |

6 | |

5 | |

10 |

Question 2 Explanation:

Question 3 |

Consider the following statements.

S1: Every SLR(1) grammar is unambiguous but there are certain unambiguous grammars that are not SLR(1).

S2: For any context-free grammar, there is a parser that takes at most O(n^3) time to parse a string of length n.

Which one of the following options is correct?

S1: Every SLR(1) grammar is unambiguous but there are certain unambiguous grammars that are not SLR(1).

S2: For any context-free grammar, there is a parser that takes at most O(n^3) time to parse a string of length n.

Which one of the following options is correct?

S1 is true and S2 is false | |

S1 is false and S2 is true | |

S1 is true and S2 is true | |

S1 is false and S2 is false |

Question 3 Explanation:

Question 4 |

A grammar is defined as

A \rightarrow B C

B \rightarrow x \mid B x

C \rightarrow B \mid D

D \rightarrow y \mid Ey

E \rightarrow z

The non terminal alphabet of the grammar is

A \rightarrow B C

B \rightarrow x \mid B x

C \rightarrow B \mid D

D \rightarrow y \mid Ey

E \rightarrow z

The non terminal alphabet of the grammar is

\{A, B, C, D, E\} | |

\{B, C, D, E\} | |

\{A, B, C, D, E,x,y,z\} | |

\{x,y,z\} |

Question 4 Explanation:

Question 5 |

A given grammar is called ambiguous if

two or more productions have the same non-terminal on the left hand side | |

a derivation tree has more than one associated sentence | |

there is a sentence with more than one derivation tree corresponding to it | |

brackets are not present in the grammar |

Question 5 Explanation:

Question 6 |

Given the grammar

s \rightarrow T^{*} S \mid T

T \rightarrow U+T \mid U

U \rightarrow a \mid b

Which of the following statements is wrong?

s \rightarrow T^{*} S \mid T

T \rightarrow U+T \mid U

U \rightarrow a \mid b

Which of the following statements is wrong?

Grammar is not ambiguous | |

Priority of + over * is ensured | |

Right to left evaluation of * and + happens | |

None of these |

Question 6 Explanation:

Question 7 |

Consider the following grammar.

S\rightarrow aSB|d

B\rightarrow b

The number of reduction steps taken by a bottom-up parser while accepting the string aaadbbb is___________.

S\rightarrow aSB|d

B\rightarrow b

The number of reduction steps taken by a bottom-up parser while accepting the string aaadbbb is___________.

5 | |

6 | |

7 | |

8 |

Question 7 Explanation:

Question 8 |

Consider the augmented grammar given below:

S'\rightarrow S

S \rightarrow \lt L \gt |id

L \rightarrow L,S|S

Let I_0=CLOSURE(\{[S'\rightarrow \cdot S]\}) . The number of items in the set GOTO(I_0,\lt) is __________.

S'\rightarrow S

S \rightarrow \lt L \gt |id

L \rightarrow L,S|S

Let I_0=CLOSURE(\{[S'\rightarrow \cdot S]\}) . The number of items in the set GOTO(I_0,\lt) is __________.

2 | |

4 | |

5 | |

6 |

Question 8 Explanation:

Question 9 |

Consider the following given grammar:

Compute the FOLLOW set of the non-terminal B and write the index values for the symbols in the FOLLOW set in the descending order. (For example, if the FOLLOW set is {a, b, d, $}, then the answer should be 3210).

Answer:_____

```
S \rightarrow Aa
A \rightarrow BD
B \rightarrow b|\epsilon
D \rightarrow d|\epsilon
```

Let a, b, d and $ be indexed as follows: Compute the FOLLOW set of the non-terminal B and write the index values for the symbols in the FOLLOW set in the descending order. (For example, if the FOLLOW set is {a, b, d, $}, then the answer should be 3210).

Answer:_____

310 | |

3100 | |

31 | |

220 |

Question 9 Explanation:

Question 10 |

Which one of the following kinds of derivation is used by LR parsers?

Leftmost | |

Leftmost in reverse | |

Rightmost | |

Rightmost in reverse |

Question 10 Explanation:

There are 10 questions to complete.

in question no. 7 there will be b instead of d in production B

S→aSB∣d

B→b

Thank You Ankush Banik,

We have updated the question.

Nice webiste , Good