Header Ads

  • Highlights

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

    What do you mean by Derivation of Grammar?

    Derivation of grammar :

    In the theory of computation derivation is the process of deriving or generating a language from the given production rules. In this non-terminal are replaced by the corresponding strings of the right-hand side (RHS) of the production. But if there is more than one non-terminal, then which should be replaced first must be determined by derivation.

    Depending on this selection, the derivation is divided into two parts:

    Leftmost derivation:

    A derivation is called a leftmost derivation if we replace only the leftmost non-terminal by some production rule at each step of the generating process of the language from the grammar.

    Rightmost derivation:

    A derivation is called a rightmost derivation if we replace only the rightmost non-terminal by some production rule at each step of the generating process of the language from the grammar.


    Construct the string 0100110 from the following grammar by using
    i) Leftmost derivation     ii) Rightmost derivation

    S → 0S/1AA

    A → 0/1A/0B
    B → 1/0BB

    Solution:
    i) Leftmost Derivation
    S → 0S → 01AA → 010BA → 0100BBA → 01001BA → 010011A → 0100110
    (The non-terminals that are replaced are represent in red.)
    ii) Rightmost Derivation
    S → 0S → 01AA → 01A0 → 010B0 → 0100BB0 → 0100B10 → 0100110
    (The non-terminals that are replaced are represent in red.)

     Also, Study about: 

    Also Read, some interview tips

    No comments

    Post Bottom Ad

    Powered by Blogger.