• edited by
511 views
1 1 vote

Consider the following grammar $G$ with the set of non-terminals $\{S, A, B\}$ and terminals $\{a, b, c, d\}$ :

$$
S \rightarrow A B c, A \rightarrow a|\epsilon, B \rightarrow b| \epsilon
$$


Which of the following is the correct $\operatorname{FIRST}(\mathrm{S})$ ?

  1. $\{a, b, c, \epsilon\}$
     
  2. $\{a, b, c\}$
     
  3. $\{a, \epsilon\}$
     
  4. $\{a, b, \epsilon\}$

4 Answers

0 0 votes

Answer option B

Given grammar

S -> ABc
A -> a | €
B -> b | €

For the given grammar in the above question the First(S) can never contain €(epsilon) because the non terminal S cannot produce €(epsilon) by itself in the production of the given grammar. So, options A and C and D are eliminated.

now,first(s) =first(ABc)={ a , fi(B)(because fi(A) has null) }

Fi(b)= { b , c(because fi(b) has null)  }

Finally fi(S) = {a,b,c}

 

Anyone please correct me if my approach is wrong. 

Answer:
Position:
Show:

Related questions

2 2 votes
5 5 answers
641
641 views
GO Classes asked Dec 26, 2025
641 views
Consider the following grammar $G$ with start symbol $E$ :$E \rightarrow T R$ $R \rightarrow+T R \mid \epsilon$ $T \rightarrow f$Which of the following statement(s) is/ar...
3 3 votes
3 3 answers
542
542 views
GO Classes asked Dec 26, 2025
542 views
Which of the following statement(s) is/are FALSE while computing $\textbf{FIRST}$ and $\textbf{FOLLOW}$ sets for a Context-Free Grammar?If $X \rightarrow \alpha$ is a pro...
1 1 vote
2 2 answers
397
397 views
GO Classes asked Dec 26, 2025
397 views
Which one of the following is FALSE?A flow graph is a directed graph where nodes represent basic blocks and edges represent the flow of control. Copy Propagation is an op...
1 1 vote
2 2 answers
358
358 views
GO Classes asked Dec 26, 2025
358 views
Which one of the following is FALSE?Reaching Definitions analysis is a forward data flow analysis problem. Live Variable analysis is used to determine which variables hol...