in Theory of Computation recategorized by
101 views
0 votes
0 votes
in Theory of Computation recategorized by
101 views

1 Answer

4 votes
4 votes
Best answer
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

2 Comments

B and C are the same right?
2
2
Yes. I forgot this thing. Thank you.
1
1

Related questions