Header Ads

  • Highlights

    👩🏻‍💻 Hello Readers 🧑🏻‍💻!!! Would you like to Explore more ? Hit on ⓘ(Ads)... ✨🌹

    Example to generate Parse tree from the given grammar


    Let us understand an example to find the parse tree for generating the string 0100110 from the following grammar.
              S → 0S/1AA
              A → 0/1A/0B
              B → 1/0BB

    Explaination :

    To generate the string 0100110 from given context free grammar, the Left most derivation will be :

    S → 0S → 01AA → 010BA → 0100BBA → 01001BA → 010011A → 0100110


    To generate the string 0100110 from given context free grammar, the Right most derivation will be :

    S → 0S 01AA  01A0  010B0 → 0100BB0 → 0100B10 → 0100110

    Although, when you find that both LMD and RMD have the same parse tree, the way to draw the parse tree is different.

    Note: When you are told to generate a parse tree, you can generate that by the leftmost derivation or the rightmost derivation.

     Also, Study about: 

    Also Read, some interview tips

    No comments

    Post Bottom Ad

    Powered by Blogger.