leftmost and rightmost derivations

RGPV 2020   
What are leftmost and rightmost derivations? Explain with suitable example ?

Grammar:

S → aS / ∈

For generating strings 'aaa'.

Left most derivation: 

A leftmost derivation is obtained by applying production to the leftmost variable in each step.

S → aS

→ aaS       (Using S → aS)

→ aaaS     (Using S → aS)

→ aaa∈

→ aaa

Right most derivation:

A rightmost derivation is obtained by applying production to the rightmost variable in each step.

S → aS

→ aaS       (Using S → aS)

→ aaaS     (Using S → aS)

→ aaa∈

→ aaa
Share:

Post a Comment

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.