CFG to GNF Conversion (Removal of Left Recursion)

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ธ.ค. 2024

ความคิดเห็น •

  • @tgtes2720
    @tgtes2720 5 ปีที่แล้ว +94

    I'm from Ethiopia and I just want to let you know that your videos are a great help! Thank you!

  • @imranshaik5325
    @imranshaik5325 3 ปีที่แล้ว +307

    Me : This question is easy.
    Z : Let me introduce myself.

  • @sandypspkt
    @sandypspkt 2 ปีที่แล้ว +17

    I'm from NEPAL 🇳🇵🇳🇵 and I just want to let you know that your videos are very helpfull ! Thank you! sir❣

  • @imprakrut
    @imprakrut 6 ปีที่แล้ว +1198

    Who is watching this one day before the exams?

  • @omdeep4137
    @omdeep4137 4 ปีที่แล้ว +41

    Your lectures are miracleous. It will definitely help to understand things better as well as to pass the exams

  • @bhanupchennam1366
    @bhanupchennam1366 6 ปีที่แล้ว +88

    Neso academy is the reason for passing my exams much impact compare to leaturea in college

  • @baldiola482
    @baldiola482 2 หลายเดือนก่อน +1

    tomorrow is my cat2 and this is the most helpful video i found on the internet.

  • @chouaibbenali5201
    @chouaibbenali5201 5 ปีที่แล้ว +134

    I had some hopes and then i saw that Z production in the end i'am like Nop..

    • @ankithareddy81
      @ankithareddy81 4 ปีที่แล้ว +6

      Same 😣

    • @imranshaik5325
      @imranshaik5325 3 ปีที่แล้ว +8

      Me : This question is easy.
      Z : Let me introduce myself.

    • @apoorv_rajput5498
      @apoorv_rajput5498 5 หลายเดือนก่อน

      Are you doing any job now ???

  • @lipsachhotray1021
    @lipsachhotray1021 7 ปีที่แล้ว +10

    thank you so much for your efforts to explain the topic so lucidly!

  • @rajkumarjagatjitsingh3829
    @rajkumarjagatjitsingh3829 7 ปีที่แล้ว +11

    thank you sir for the conclusion in such a short time.

  • @satyayadav4501
    @satyayadav4501 2 ปีที่แล้ว +1

    Neso academy is only choice to learn all my subjects it is not only help to pass the exams ..it is also give a me best knowledge upon respected subjects....thank you so much 🙏

  • @chetanreddy6128
    @chetanreddy6128 ปีที่แล้ว +1

    This is the easiest way I've watched whole in the TH-cam!

  • @ranitbarman6471
    @ranitbarman6471 2 ปีที่แล้ว +36

    Why does it seem like normal forms are increasing the complexity more rather than reducing it......

  • @damianwysokinski3285
    @damianwysokinski3285 3 ปีที่แล้ว +4

    Thanks man for the video.
    I can’t belive that I need to waste time learning this stuff during my master CS studies…

  • @jayshrikhamk97
    @jayshrikhamk97 4 ปีที่แล้ว +1

    I'm from India ...ur videos is very helpful me ..in that lockdown..corona situation s

  • @asutoshpanda8807
    @asutoshpanda8807 5 ปีที่แล้ว +7

    Thanks for the simplicity u use to make the concept clear😊

  • @afraaalmoala3133
    @afraaalmoala3133 6 ปีที่แล้ว +1

    Thanks alot >. regards from the heart of Africa from Sudan .

  • @prindamuthukrishnan4134
    @prindamuthukrishnan4134 2 ปีที่แล้ว +3

    Good and awesome teaching easily understand by everyone 👏👏and very clear for me👍

  • @RockStar-Siblings
    @RockStar-Siblings 4 ปีที่แล้ว +2

    a big appaluse for ur hardwork dedication and simple,neat and clear explanation.thank u very much ..!!! ur every video really helped me a lot.

  • @vinayaksharma-ys3ip
    @vinayaksharma-ys3ip 3 ปีที่แล้ว +3

    Thanks you so much Sir.....really all your hard work is being reflected through your videos👍👍💯💯💯

  • @amitch.in7
    @amitch.in7 6 ปีที่แล้ว +3

    Thank You.
    You saved my semester.

  • @dard-e-dil3101
    @dard-e-dil3101 2 ปีที่แล้ว +1

    It's really helpful ❣️thanks neso academy 🙏

  • @pradeepkumarsingh6964
    @pradeepkumarsingh6964 5 ปีที่แล้ว +5

    sir , u are amazing , thnx a lot for teaching TOC in such efficient manner

  • @nicksbinarylife
    @nicksbinarylife 6 ปีที่แล้ว +8

    Having a quiz tomorrow, Thank you Neso academy for helping me out !

    • @drkaranmannan
      @drkaranmannan 4 ปีที่แล้ว

      bhai same.

    • @blitzkrieg7453
      @blitzkrieg7453 ปีที่แล้ว

      how did you perform in the quiz?

    • @nicksbinarylife
      @nicksbinarylife ปีที่แล้ว +7

      @@blitzkrieg7453 hhhh I passed the course, graduated 3 years ago and now working 😂

    • @blitzkrieg7453
      @blitzkrieg7453 ปีที่แล้ว +1

      @@nicksbinarylife wow that’s great!

    • @Al0w1n
      @Al0w1n 2 หลายเดือนก่อน

      The cycle repeats.

  • @shravyagowda1024
    @shravyagowda1024 2 ปีที่แล้ว +1

    Thank you so much sir!!! This was really helpful during exams🙏

  • @jonaskoelker
    @jonaskoelker 2 ปีที่แล้ว +2

    I had an insight about left recursion I would like to share:
    Let's say you have a left-recursive grammar T -> T + F | F and F -> 1.
    The partially expanded derivations / parse trees look like T, (T + F), ((T + F) + F), (...(T + F) + F) + F) ...), where the path from the 'T' root to the leftmost leaf is where the left recursion happens, or rather not to a leaf but to the point where T is replaced by some non-left-recursive production, i.e. the point were we use T -> F rather than T -> T + F. [Suggestion: draw or envision a diagram until this clicks for you.]
    Removing left recursion essentially means parsing that part of the tree in a bottom-up rather than top-down fashion.
    For example, let's rewrite my grammar to S -> F | FK and K -> + F | + F K and F -> 1 and let's derive 1 + 1 + 1. Note that S and K together replace T.
    So we go S -> FK -> 1K -> 1 + F K -> 1 + 1 K -> 1 + 1 + F -> 1 + 1 + 1.
    Whenever we add more factors (adding "+ F" ~ adding one more layer to the parse tree) we're always replacing the right-most non-terminal. But when we're expanding F, which is not part of the left recursion (except as an ultimate output as it were), we're replacing the left-most non-terminal. [Recall that left-most is top-down and right-most is bottom up: we see that the left-recursive part is handled bottom-up, but everything outside it can still be handled top-down]

  • @Umarfarooq-ee9nl
    @Umarfarooq-ee9nl 7 ปีที่แล้ว +20

    Thanks sir. I had doubts on this topic, now it's ok. Tomorrow is my exam. This topic is confusing on the book. Thanks again

    • @hotaru6765
      @hotaru6765 6 ปีที่แล้ว +1

      I know this was written 6 months ago but same here lol,
      mine is tomorrow too

    • @amitthakur-ky9hq
      @amitthakur-ky9hq 6 ปีที่แล้ว

      @Swargam Hazarika i know this was written 2 weeks ago but i have my exam tomorrow too. LMAO!!!

    • @dhairyaanchal8623
      @dhairyaanchal8623 6 ปีที่แล้ว

      @@amitthakur-ky9hq i know this was written 2 days ago but i too have my exam 2moro, #lol

    • @Mazino420
      @Mazino420 5 ปีที่แล้ว +1

      @@dhairyaanchal8623 i know this was written 9 months ago but i have my exam tomorrow lmaaao🤣🤣

    • @vinayak186f3
      @vinayak186f3 3 ปีที่แล้ว

      @@Mazino420 I know last comment was written 1 yr ago but I too have my exam tomorrow . LoL

  • @kanimozhin8177
    @kanimozhin8177 3 หลายเดือนก่อน +1

    4:32 shouldn't A3 also be removed since 4>3? It does not satisfy GNF conditions

  • @haythama8563
    @haythama8563 6 ปีที่แล้ว +12

    Shouldn't we convert Z to A5 or something like that? in GNF we should have one Terminal followed by Non-Terminals lets say A in ascending order (or index) , but Z is not A?!

  • @annc4196
    @annc4196 3 ปีที่แล้ว +2

    How about A3, shouldn't you replace it with a? as 3 is less than 4?

  • @adeshkumarsahoo6256
    @adeshkumarsahoo6256 6 ปีที่แล้ว +1

    Thank you very much Neso Academy
    .......very much greatful to you..

  • @Apoorvpandey
    @Apoorvpandey 3 ปีที่แล้ว +5

    This looks incredibly complex, but the steps make it simple!

  • @dhruvsharma5786
    @dhruvsharma5786 6 หลายเดือนก่อน

    Dhanyawad Sirji❤❤❤❤❤

  • @AkashBharadwaj-cz4eo
    @AkashBharadwaj-cz4eo 8 วันที่ผ่านมา

    Thanks a lot sir, it was really helpful

  • @sek3254
    @sek3254 ปีที่แล้ว +1

    you saved me !!!!!!!!!!!!!! Thank you

  • @mahimaverma1572
    @mahimaverma1572 7 ปีที่แล้ว +4

    Plz upload vedios of pda n Turing machine ...

  • @gauravbhandari1184
    @gauravbhandari1184 6 ปีที่แล้ว

    Got it at very first time.
    Love from Nepal..

  • @Rohit_Yadav008
    @Rohit_Yadav008 ปีที่แล้ว +2

    Sir dhuye Uda diye🥲🥲🥲

  • @arnodunstatter
    @arnodunstatter 3 ปีที่แล้ว +14

    Can you do an explanation of how A4 -> b | b A3 A4 | A4 A4 A4 can be shown to be equivalent to A4 -> b | b A3 A4 | b Z | b A3 A4 Z
    where Z = A4 A4 Z | A4 A4?

    • @marxman1010
      @marxman1010 3 ปีที่แล้ว +3

      Can't find a decent explanation from the web, too.

    • @WilliamLaurenson
      @WilliamLaurenson 22 วันที่ผ่านมา

      Y'all, I'm stuck on this too and I wish he could've just explained it lol. How did he get "bZ" and "b A3 A4 Z"?
      Edit: Nvm, I think I figured it out.
      In the new production rule,
      "A4" can produce "b", "b A3 A4", "bZ", and "b A3 A4 Z".
      "bZ" is basically just "A4 A4 A4" but the first "A4" is replaced with "b" because "A4 -> b" ("A4" can produce the terminal "b").
      The two "A4" which follow the first can be replaced with Z because
      Z -> A4 A4. The end result is "bZ" which was originally "A4 A4 A4".
      "b A3 A4 Z" is basically just "A4 A4 A4" but the first A4 is replaced with "b A3 A4" because
      "A4 -> "b A3 A4". The two "A4" which follow the first can also be replaced with Z like we have already done before so that the result of transforming "A4 A4 A4" is "b A3 A4 Z".
      "A4 A4 A4" = A4 (A4 -> b A3 A4) A4 A4 (Z -> A4 A4) = "b A3 A4 Z"
      I'm so sorry if my explanation is messy and informal but this is how I understood it.

  • @revathireshma5198
    @revathireshma5198 5 ปีที่แล้ว +2

    Thank you..sir I understood 👍👍

  • @neeraj8867
    @neeraj8867 3 ปีที่แล้ว

    all the best for all your sem exams we will meet in future

  • @scimitar_0096
    @scimitar_0096 6 ปีที่แล้ว +4

    In the last Z-> b(A3)(A4)(A4)Z should be "b(A3)(A4)Z(A4)Z"
    By the way nice videos.

    • @elyasaf755
      @elyasaf755 5 ปีที่แล้ว +1

      It is fine in the video and should remain the same

  • @kisnagoyal9694
    @kisnagoyal9694 7 หลายเดือนก่อน +1

    for those who have confusion in z... we are skipping 1st A4 and writing remaining A4's then Z..

  • @AmandeepSingh-qj5qg
    @AmandeepSingh-qj5qg 2 ปีที่แล้ว

    Watching 2 hrs before the exams 👍👍💪

  • @geethageethu1471
    @geethageethu1471 6 ปีที่แล้ว +3

    But, A2 -> b becomes a useless production?, since we have replaced all the values of A2 with b

  • @divyarani5128
    @divyarani5128 3 ปีที่แล้ว +2

    Is this the actual way for solving left recursion? I think there is some other way for that. Then why are we solving it like this ..is it enough? I don't understand 🙁

  • @ayanmandal8257
    @ayanmandal8257 4 ปีที่แล้ว +3

    Sir, suppose if the production was A1-A4A4 then after creating z production what i write in new productiom A1?

  • @dhanarajs2707
    @dhanarajs2707 5 ปีที่แล้ว

    muthey.... nee life saveraaadaaa

  • @Greg-mo8bd
    @Greg-mo8bd 6 ปีที่แล้ว

    Wonderful teaching

  • @sandhya6312
    @sandhya6312 6 ปีที่แล้ว

    👌👌👌 explanation.grateful to uu.loved it

  • @visakhakenguva9698
    @visakhakenguva9698 6 ปีที่แล้ว

    Thanks a lot sir for your clear explanation

  • @shreyashchoudhary4576
    @shreyashchoudhary4576 3 ปีที่แล้ว

    Really very helpful!

  • @niteshdewangan7522
    @niteshdewangan7522 5 ปีที่แล้ว +1

    Tis is life saving

  • @Ind_yours
    @Ind_yours 7 ปีที่แล้ว

    Awesome tutorial sir

  • @zedx4749
    @zedx4749 ปีที่แล้ว +1

    Watching this 30 minutes before the exam.

  • @piyushchaudhari397
    @piyushchaudhari397 5 ปีที่แล้ว

    Thank u so much nesco academy

  • @vineethreddymadadi7940
    @vineethreddymadadi7940 6 ปีที่แล้ว +2

    Awesome, thanks a lot!

  • @bisatisrilatha7957
    @bisatisrilatha7957 4 ปีที่แล้ว

    Tq so much continue 🙏🙏🙏

  • @divyamsh2115
    @divyamsh2115 6 ปีที่แล้ว +5

    My sir's explanation was pure shit..this video helped me a lot

  • @sobhantahamolian1578
    @sobhantahamolian1578 11 หลายเดือนก่อน

    sorry I have a question. for left recursion, the second product shouldn't be epsilon?
    I mean: z -> A4A4Z | epsilon

    • @artifice_abhi
      @artifice_abhi 9 หลายเดือนก่อน

      but there can't be any null productions so when we remove it, the result will be the same shown in the video.

    • @sobhantahamolian1578
      @sobhantahamolian1578 9 หลายเดือนก่อน

      @@artifice_abhi yes thank you,after i saw the compiler design course, I understood that he does a epsilon reduction at the same time.

  • @GDX17
    @GDX17 2 ปีที่แล้ว

    now how would you convert this to a simple grammar?

  • @REACTORGAMING444
    @REACTORGAMING444 6 ปีที่แล้ว +2

    What is the use of CNF and GNF in real life

    • @skerdxhafa8108
      @skerdxhafa8108 5 ปีที่แล้ว

      depends on what you do for a living

    • @srishtidixitsd
      @srishtidixitsd 5 ปีที่แล้ว

      Makes parsing easy! Enables recursive descent parsing!

    • @imranshaik5325
      @imranshaik5325 3 ปีที่แล้ว

      To pass in exam 😂😂

  • @laisdeghaide9853
    @laisdeghaide9853 2 ปีที่แล้ว +1

    Thank you sir, I would like to know how to convert this CFG to GNF, can you please help me?
    S -> A | S + A
    A -> B | AB
    B -> (S) | a | b | c

  • @collegematerial5348
    @collegematerial5348 2 ปีที่แล้ว

    At 3:17 A4 is given three times but you have used only two times why along with Z anybody can tell

    • @bhavyabhagwani5407
      @bhavyabhagwani5407 ปีที่แล้ว

      because only two are problematic as I >j and then i=j

  • @TaniaDevi-p8e
    @TaniaDevi-p8e ปีที่แล้ว

    where did bZ come from at 4:50

  • @manjarinandimajumdar2642
    @manjarinandimajumdar2642 3 ปีที่แล้ว

    Thank you so much for this amazing explanation. Helped me loads.

  • @mahimdhungel6777
    @mahimdhungel6777 7 ปีที่แล้ว +1

    if i

    • @nikhilmahato5771
      @nikhilmahato5771 6 ปีที่แล้ว +2

      Off course but that form is not allowed in gnf

  • @johnbabu4042
    @johnbabu4042 ปีที่แล้ว

    Thankyou 💗💗

  • @siddharththakur2411
    @siddharththakur2411 ปีที่แล้ว +1

    Thanks

  • @parthnakti4991
    @parthnakti4991 ปีที่แล้ว

    I have a doubt, you completely merged Z with A4 but didn't did the same with A1 and partially merged it?

  • @anshjain257
    @anshjain257 5 ปีที่แล้ว

    Whats the point of converting them to increasing order when they aate to be replaced by some terminals

  • @pranav7911
    @pranav7911 2 ปีที่แล้ว +1

    No simple explanation on yt than this

  • @waklord1830
    @waklord1830 ปีที่แล้ว

    its b A3 A4 rater than b A3 A4 z they must have missed something if ur confused just remove z from eq , Thank you

  • @harshdasadgir3292
    @harshdasadgir3292 5 ปีที่แล้ว

    Tysm sir very helpful

  • @debanjanghosal618
    @debanjanghosal618 6 หลายเดือนก่อน +1

    If this comes in uni exam, this better be worth atleast 30 marks!

  • @sportstv1217
    @sportstv1217 3 ปีที่แล้ว

    4.18 why bZ?

  • @shannu7441
    @shannu7441 2 ปีที่แล้ว

    I am watching on the day of examination

  • @李霁野-b5w
    @李霁野-b5w 7 ปีที่แล้ว +1

    A4 -> bA3A4 is satisfy this form? 3< 4

    • @shivenmehru1571
      @shivenmehru1571 7 ปีที่แล้ว +3

      check the definition of GNF it also says a terminal symbol followed by non terminals is in GNF

    • @worldsituation9892
      @worldsituation9892 7 ปีที่แล้ว +1

      because we jst worry about first variable not 2nd and 3rd....;)

  • @akankshasharma7498
    @akankshasharma7498 3 ปีที่แล้ว

    Isn't Z violating the rules? How is Z a part of A1, A2....An? Also, why is A4A4 allowed?

  • @Sruthimugle
    @Sruthimugle ปีที่แล้ว

    sir but in A4 -> b|bA3A4|bz|bA3A4Z A4> A3 i>j so is it right ? don't we have to make any changes

    • @prathamdwivedi106
      @prathamdwivedi106 ปีที่แล้ว +1

      I have the same doubt. But I think once you get a terminal symbol in the beginning you don't need to check further

    • @tonypepper
      @tonypepper 11 หลายเดือนก่อน +2

      Checking is done for Ai->Aj X.... Ai, Aj non terminal symbols.
      Not for Ai-> a(some terminal symbol) Aj.
      Only when right side of that production start with a non terminal which has i>=j

  • @arushirastogi3805
    @arushirastogi3805 7 ปีที่แล้ว +3

    LOVE

  • @karmanminocha
    @karmanminocha 6 ปีที่แล้ว +1

    What if there is a case in left recursion where the problematic production lies in between the two variables.
    that is, here the problematic A4 lies in the beginning and the rest of them are easily changed with by adding Z after them but can there be a case when it lies in the middle, if yes then how to proceed with left recursion then.

    • @bluefog68
      @bluefog68 6 ปีที่แล้ว +1

      The problematic variable should be the first one to appear on the RHS in the case of a left recursion. If it is some other variable, you can substitute it from the corresponding production and proceed, as this is not a case for a left recursion.

    • @jonaskoelker
      @jonaskoelker 6 ปีที่แล้ว

      I recommend www.csd.uwo.ca/~moreno/CS447/Lectures/Syntax.html/node8.html - The short story is that eliminating all "A_i → A_j α" productions where j

    • @shaifaliverma153
      @shaifaliverma153 5 ปีที่แล้ว

      @@bluefog68 what if ...there would have been no variable after the problematic variable......then how are we supposed to write production rule for Z.

    • @bluefog68
      @bluefog68 5 ปีที่แล้ว

      @@shaifaliverma153 then the production rule is trivial (A4 -> A4), and can be ignored in consideration, as its the identity rule.

    • @shaifaliverma153
      @shaifaliverma153 5 ปีที่แล้ว

      @@bluefog68 oh ya...thanks!

  • @virtualgamerz7345
    @virtualgamerz7345 2 ปีที่แล้ว +1

    This method is not working on other questions

  • @maheshvangala8472
    @maheshvangala8472 6 ปีที่แล้ว

    nice explaination

  • @nobody6150
    @nobody6150 2 ปีที่แล้ว

    sir why didn't you remove A3 as A3 < A4

  • @sanikaardekar69
    @sanikaardekar69 2 ปีที่แล้ว

    Thank you!

  • @hotaru6765
    @hotaru6765 6 ปีที่แล้ว +2

    Sir, Do we need to replace values of A1,A2,A3 that we assumed in the beginning after solving the problem???

    • @ragulr
      @ragulr 5 ปีที่แล้ว +1

      good question, no need to replace it back

  • @Ex-Coder
    @Ex-Coder 3 ปีที่แล้ว

    Awesome.....sir

  • @mhda-c9m
    @mhda-c9m 5 ปีที่แล้ว

    شكراً لك

  • @rohitashwapratapsingh142
    @rohitashwapratapsingh142 2 ปีที่แล้ว

    THANKYOU SIR

  • @Shirin-bx9xj
    @Shirin-bx9xj 6 หลายเดือนก่อน

    Don't we need to remove the A2->b production since it is useless at the end

  • @tusharverma2212
    @tusharverma2212 6 ปีที่แล้ว +1

    any body tell me what is left recursion here ?

    • @prateeknatani9321
      @prateeknatani9321 6 ปีที่แล้ว

      Tushar Verma when all the variables are same

    • @tusharverma2212
      @tusharverma2212 6 ปีที่แล้ว

      @@prateeknatani9321 ok

    • @prateeknatani9321
      @prateeknatani9321 6 ปีที่แล้ว +1

      A3-->A3A2A1 leads to left recursion when a variable refers itself

  • @arunarkamukhopadhyay6443
    @arunarkamukhopadhyay6443 5 ปีที่แล้ว

    Can we replace A4 directly with 'b'?

    • @ragulr
      @ragulr 5 ปีที่แล้ว

      nope

  • @AhamedKabeer-wn1jb
    @AhamedKabeer-wn1jb 4 ปีที่แล้ว

    Thanks Sir...

  • @karmaexists6410
    @karmaexists6410 6 ปีที่แล้ว

    Is it important to check for left recursion if we are going to convert CFG into CNF?

  • @event9123
    @event9123 5 ปีที่แล้ว

    Complex but good ...

  • @trywellwashington7506
    @trywellwashington7506 4 ปีที่แล้ว +2

    step ending 4:21 seems strange

  • @shivomsaxena1581
    @shivomsaxena1581 7 ปีที่แล้ว +1

    sir is turing machine is the upcoming topic??

  • @manikanta-oh3qy
    @manikanta-oh3qy 7 ปีที่แล้ว +1

    sir plz upload control systems video lectures

  • @ishitachatterjee4709
    @ishitachatterjee4709 6 ปีที่แล้ว +1

    I couldn't understand why we got bZ in A4

    • @kashif2309
      @kashif2309 4 ปีที่แล้ว

      I know it's late but he discussed that part in his previous video on the very same topic.