Define a context-free-grammar that has only strings in L (G) are a^n b^n for n ≥ 1.

Define a context-free-grammar that has only strings in L (G) are an bn for n ≥ 1.


We can represent a CFG (G) by its four components that is
G = (V, T, P, S)
Where,
V = The set of variables
T = The set of terminals
P = The set of production
S = The start symbol
Here,
V = {s}
T = {a, b} and
P consists of the following rules.
{1. S → asb & 2. s → ab}
Whenever rule 1 is applied one ‘a’ is generate generate on the left and one ‘b’ the right. The derivation terminals by using rule 2. A simple derivation and derivation tree one given below:
S → asb
→ aasbb
→ aaasbbb
→ aaaasbbbb
   ---   ---   ---   ---   ---
   ---   ---   ---   ---   ---
   ---   ---   ---   ---   ---
A simple derivation tree



No comments

Dear Members, Thanks for Your Comments. We must be reply your comment answer as soon as possible. Please Stay with us.....

Theme images by ideabug. Powered by Blogger.