Ambiguity in CFGs - Solved Problems (Set 1)

Поділитися
Вставка
  • Опубліковано 10 лют 2025
  • Compiler Design: Ambiguity in CFGs - Solved Problems (Set 1)
    Topics discussed:
    1. UGC-NET December 2018 solved PYQ of Ambiguity in Context Free Grammars.
    2. UGC-NET June 2018 solved PYQ of Ambiguity in Context Free Grammars.
    Follow Neso Academy on Instagram: @nesoacademy (bit.ly/2XP63OE)
    Contribute: www.nesoacadem...
    Memberships: bit.ly/2U7YSPI
    Books: www.nesoacadem...
    Website ► www.nesoacadem...
    Forum ► forum.nesoacad...
    Facebook ► goo.gl/Nt0PmB
    Twitter ► / nesoacademy
    Music:
    Axol x Alex Skrindo - You [NCS Release]
    #CompilerDesignByNeso #CompilerDesign #AmbiguityInCFGs

КОМЕНТАРІ • 37

  • @yenzyhebron5278
    @yenzyhebron5278 11 місяців тому +2

    Hi I'd like to point out that for a grammar to be classified as ambiguous using a parse tree derivation, the grammar has to have either two or more left most parse tree derivation or two or more right most parse derivation for the same input string.
    Please don't leave this out. Specify if your parse true will only do leftmost derivation or rightmost derivation.

    • @年知ろはると
      @年知ろはると 21 день тому

      hello I have a question:
      5:37 the parse tree at the right doesnt seem acceptable since at the left tree he started from 'a' input but at the right tree he started with the 'b' input (and in predictive parsing you can't really advance then backtrack), so aren't they completely different trees?
      and if that's the case is G1 actually not ambiguous? please correct me if i'm wrong

  • @iosifpuha6114
    @iosifpuha6114 Рік тому +8

    Hello, I just don't understand a thing: you said that to determine if a grammar is unambiguous or not is an undecidable problem, so there's no concrete approach/algorithm to do that but then you proceeded to prove that that grammar is ambiguous, using the ()()() string, how did you come up with that? I mean, how should I know what string to use in order to make it work?

    • @legityash
      @legityash Рік тому +1

      By practicing, just like we do in Trigonometry.

    • @josemarichan1183
      @josemarichan1183 4 місяці тому +1

      Determining if a grammar can be ambiguous is undecidable. We have no concrete method or algorithm for that because there are infinite possible inputs. However, when we are given a particular input, determining ambiguity for that is now decidable/solvable.

  • @年知ろはると
    @年知ろはると 21 день тому

    i'm sorry, please correct me if i'm wrong @NesoAcademy
    but on 5:37 the parse tree at the right doesnt seem acceptable since at the left tree you started from 'a' input but at the right tree you started with the 'b' input (and in predictive parsing you can't really advance then backtrack), so aren't they completely different trees?
    and if that's really the case then G1 isn't ambiguous.

  • @eminence_Shadow
    @eminence_Shadow Рік тому +13

    How did you know what to derive??

    • @854Rri
      @854Rri Рік тому +5

      Just generate any input from the grammar and test it

    • @ritvikupadhyay4677
      @ritvikupadhyay4677 Рік тому +1

      @@854Rri but what if the input that i generate doesnt necessarily have another way to derive it?

    • @IlIIlIIlIlIlIIlIIlI
      @IlIIlIIlIlIlIIlIIlI 11 місяців тому +1

      @upadhyay4677 I don't know if I understand it right, but you have to test another input then. Till you are sure (or can prove) that it is ambiguous or not

    • @princenedjoh
      @princenedjoh 6 місяців тому

      You would have to generate it using the set of terminals given

  • @kaselunt472
    @kaselunt472 2 роки тому +4

    Thanks for this extremely well-made content, you are a lifesaver! Quick question: how did you decide what strings to test with?
    You used ababa, and then ab. Just wondering if those were given with the question or if you chose them somehow. Thanks again!

    • @rajeshprajapati6662
      @rajeshprajapati6662 Рік тому

      You just start with something and in the process of generation you will get some strings. Take them and try to make two parse trees. I solved like this both questions on my own. Thanks to him. It is not necessary to have strings in the beginning.

  • @derriekxavier
    @derriekxavier Рік тому +4

    at 3:33, how is it ambigous when both trees are the same and have the same result?

    • @rajeshprajapati6662
      @rajeshprajapati6662 Рік тому +1

      How both trees are same ? they are different for the same expression. See his lectures carefully, he has already explained your answer in previous videos.

  • @arjungaming2706
    @arjungaming2706 2 роки тому

    Sir your lectures are awesome and with easy explanation sir can you uplode more lectures plzzz

  • @monicabattacharya6416
    @monicabattacharya6416 2 роки тому +2

    Thank you so much for uploading this video sir 😊🙏🙏🙏.

  • @soomaaliga_xalaasha_ah
    @soomaaliga_xalaasha_ah Рік тому +2

    4:46 if not given how would you come up with 'ababa' ?

    • @BaHuynh-rs5lj
      @BaHuynh-rs5lj 11 місяців тому

      same )) how you know ababa ? and where is that ?. How about I come with "a". S -> a (only 1 tree, then it is not ambigous?). Other hand, If the grammar too complex or like 1000 rules. How we know the string like "ababa" ?

  • @riyansh3396
    @riyansh3396 Рік тому +1

    At 5:57 you have made 2 parse tree one is left most and another is right most, so how can it be Ambiguous Grammar

    • @IlIIlIIlIlIlIIlIIlI
      @IlIIlIIlIlIlIIlIIlI 11 місяців тому

      A Context Free Grammar is ambiguous, when to every word only one derivation tree exists. The derivation trees of left most and right most are different, so it is ambiguous. It also follows that either left most or right most derivation has ambiguous trees. This is also noticeable in the trees shown, because both trees could be derived from a left most derivation.

    • @killMan5746
      @killMan5746 11 місяців тому

      yeah hes wrong

    • @年知ろはると
      @年知ろはると 21 день тому

      @@IlIIlIIlIlIlIIlIIlI i don't get it, can you dumb it down for me? xD

  • @marvel_ethio-k4p
    @marvel_ethio-k4p Місяць тому

    since it is a question,so how you take the strings ababa and ab

  • @none9304
    @none9304 9 місяців тому +2

    1:55 ahh yes SS :) iykuk

  • @monicabattacharya6416
    @monicabattacharya6416 2 роки тому

    To take your payment course , it's asking GST.
    What we have to enter?
    Please reply sir 😊

    • @nesoacademy
      @nesoacademy  2 роки тому

      Hello, you can leave this field empty. It is for the people/company having a GST Number.

    • @monicabattacharya6416
      @monicabattacharya6416 2 роки тому

      @@nesoacademy what is GST number?

    • @rajeshprajapati6662
      @rajeshprajapati6662 Рік тому

      @@monicabattacharya6416 GSTIN, short for Goods and Services Tax Identification Number, is a unique 15 digit identification number assigned to every taxpayer (primarily dealer or supplier or any business entity) registered under the GST regime.

  • @sakshijadhav6394
    @sakshijadhav6394 Рік тому

    what is string for Q1 ?

  • @harshithashetty233
    @harshithashetty233 2 роки тому

    Can u share the link of queue in data structure