Getting 4 but given ans is 2

The Gateway to Computer Science Excellence

+1 vote

$First (S) = First(A) = First(B)= {\{a, b, \epsilon}\} \\ Follow (S)= {\{a, b, \$} \}$

$Follow (A)= {\{a, b} \}$

$Follow (B)= {\{a, b, \$} \}$

LL(1) Parse Table:

$a$ | $b$ | $ | |

$S$ |
$S\rightarrow aAbB$ $S\rightarrow \epsilon$ |
$S\rightarrow bAaB$ $S\rightarrow \epsilon$ |
$S\rightarrow \epsilon$ |

$A$ | $A\rightarrow S$ | $A\rightarrow S$ | |

$B$ | $B\rightarrow S$ | $B\rightarrow S$ | $B\rightarrow S$ |

2 multiple entries

**Hence 2 is the correct answer**

0

now, why not there is entry for A--->ϵ under T[A,a], T[A,b]

similarly, why not there is entry for B--->ϵ under T[B,a], T[B,b] , T[B,$]

similarly, why not there is entry for B--->ϵ under T[B,a], T[B,b] , T[B,$]

+1

Yes, it is driving but we didn't add it into the table, we add only those entries present in grammar.

See LL(1) is a predictive parser, on the basis of current input symbol it decides which grammar production it will select.

Suppose at any instant when next input symbol is 'a' which is in first of A then production A->S is selected by parser

LL(1) table contains only productions present in grammar

See LL(1) is a predictive parser, on the basis of current input symbol it decides which grammar production it will select.

Suppose at any instant when next input symbol is 'a' which is in first of A then production A->S is selected by parser

LL(1) table contains only productions present in grammar

- All categories
- General Aptitude 1.9k
- Engineering Mathematics 7.5k
- Digital Logic 2.9k
- Programming and DS 4.9k
- Algorithms 4.4k
- Theory of Computation 6.2k
- Compiler Design 2.1k
- Databases 4.1k
- CO and Architecture 3.4k
- Computer Networks 4.2k
- Non GATE 1.4k
- Others 1.4k
- Admissions 595
- Exam Queries 573
- Tier 1 Placement Questions 23
- Job Queries 72
- Projects 18

50,737 questions

57,317 answers

198,367 comments

105,096 users