recategorized by
318 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

2.4k
views
1 answers
1 votes
M_Umair_Khan42900 asked Dec 29, 2022
2,407 views
Write regular expression to denote a language La) String which begin or end with either 00 or 11.b) The set of all strings, when viewed as binary ... The set of all strings containing 00.d) String not containing the substring 110.
387
views
0 answers
0 votes