4 votes 4 votes The grammar shown below is LL(k) for some value of k. What is the smallest value of k for which this grammar is LL(k)? Compiler Design goclasses2024-mockgate-14 numerical-answers compiler-design parsing ll-parser 2-marks + – GO Classes asked Feb 5 • edited Feb 5 by Lakshman Bhaiya GO Classes 952 views answer comment Share Follow See all 14 Comments See all 14 14 Comments reply shadymeee commented Feb 6 reply Follow Share in the answer it's given k =3 can anyone please explain how? why k can't be 2 3 votes 3 votes DEEPAL123 commented Feb 6 i moved by DEEPAL123 Feb 7 reply Follow Share same doubt 0 votes 0 votes Extra_Sauce commented Feb 6 reply Follow Share Having K as 3 will also cause problem. Have a look at my logic below:K can't be 1 as grammar will not be LL(1) because FIRST1(A) are same for both productions of A.K can't be 2 as grammar will again violate LL(2) as FIRStT2(A) is okay but FIRST2(S) will have 'aa' i.e, same for 2 out of 4 productions of S.Even K as 3 will not satisfy,as FIRST3(S) will clash for input starting with 'bab'.K should be greater than 3, I think. 0 votes 0 votes shadymeee commented Feb 6 reply Follow Share how will first of S will have aa???? 0 votes 0 votes Extra_Sauce commented Feb 6 i edited by Extra_Sauce Feb 6 reply Follow Share See, the grammar given here is very simple. It can parse only four strings : aaa, aaba, bab, babb. For a grammar to be LL(k), I can see from those four strings that i need atleast 4 character lookahead on any input to decide what production to use. Got the idea? 2 votes 2 votes practicalmetal commented Feb 6 reply Follow Share @GO Classes Please provide solution for this question 1 votes 1 votes Archie19 commented Feb 6 reply Follow Share Can't we do like this? Lets subsitute: S-->aaa/aaba/bab/babb Now as we can see k=1,2 or 3 will not work. I think answer should be 4. 6 votes 6 votes Shubham Sharma 2 commented Feb 6 reply Follow Share First we put A->a in S and we get aaa , bab , so k=3. Next we put A->ab in S and we get aaba, babb, so k=4 Minimum value for k will be 3. 2 votes 2 votes mohit7891 commented Feb 6 reply Follow Share @GO Classes Answer should be 4 0 votes 0 votes Psy Duck commented Feb 6 reply Follow Share how is this an answer 0 votes 0 votes Priyotosh2001 commented Feb 7 reply Follow Share I also think like that .. becuase all of 1,2,3 are producing not LL(k) grammar. 0 votes 0 votes shadymeee commented Feb 7 reply Follow Share actually we are looking ahead by 3 symbols excluding the current symbol so ig 3 can be the answer 1 votes 1 votes rexritz commented Feb 8 reply Follow Share @Deepak Poonia please provide a solution for this question 0 votes 0 votes krishnajsw commented Feb 8 reply Follow Share https://www.youtube.com/live/CFoJsU6nvq4?si=yj8zQGTXXhGni2jq&t=6021 check here.. 0 votes 0 votes Please log in or register to add a comment.