recategorized by
241 views

1 Answer

Best answer
4 votes
4 votes
Consider input alphabet $\Sigma = \{0,1,2,3,4,5,6,7,8,9\}$ and set of Non-Terminals as $\{A,B,C\}$

Assuming grammar is for positive odd integers upto 999.

So, grammar is:

$A \rightarrow CB1\ | \ CB3 \ | \ CB5 \  | \  CB7\  | \  CB9$

$B \rightarrow 0 \ | \ 1 \ | \ 2 \ | \ 3 \ | \ 4 \ | \ 5 \ | \ 6 \ | \ 7 \ | \ 8 \ | \ 9$

$C \rightarrow 0 \ | \ 1 \ | \ 2 \ | \ 3 \ | \ 4 \ | \ 5 \ | \ 6 \ | \ 7 \ | \ 8 \ | \ 9$

Edit: As Arjun sir has mentioned below, B and C are same. So, we can also write it as:

$A \rightarrow BB1\ | \ BB3 \ | \ BB5 \  | \  BB7\  | \  BB9$

$B \rightarrow 0 \ | \ 1 \ | \ 2 \ | \ 3 \ | \ 4 \ | \ 5 \ | \ 6 \ | \ 7 \ | \ 8 \ | \ 9$
selected by

Related questions

0 votes
0 votes
0 answers
4