Question

Design a regular grammar to generate the set of all even integers. Design a regular grammar to generate the set of all odd integers. Design a regular grammar to generate the set of all integers beginning with the digit 8 such that the digits are consecutive and even. If a digit is 8, its following digit (if present) will be 0. The set of valid strings is {8, 80, 802,8024, 80246, 802468,...) Design a regular grammar to generate the set of all integers that begin with a digit having a remainder of 3 when divided by 4. Any non-ending digit having a remainder of 3 when divided by 4 will be immediately followed by a digit having a remainder of 2 when divided by 4, and vice versa. The set of valid strings is (3, 32, 36,7,72,76,323, 327, 363, 367,723, 727,763,767,...^ 6. 7. 8. 9.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

REGULAR GRAMMAR FOR SET OF ALL EVEN NUMBERS
Last digit of the number will be even, which is taken care by the production S`.

S-> 0S | 1S | 2S | 3S | 4S | 5S | 6S | 7S | 8S | 9S | S`
S`-> 0 | 2 | 4 | 6 | 8

REGULAR GRAMMAR FOR SET OF ALL ODD NUMBERS
Last digit of the number will be ODD, which is taken care by the production S`.

S-> 0S | 1S | 2S | 3S | 4S | 5S | 6S | 7S | 8S | 9S | S`
S`-> 1 | 3 | 5 | 7 | 9


REGULAR GRAMMAR TO GENERATE THE SET OF ALL INTEGERS BEGINING WITH 8
HERE THIS PRODUCTION BEGINS THE NUMBER WITH 8, AFTER 8 WE WILL HAVE 0, AND 2 AND 4 CONSECUTIVELY, WHICH IS TAKEN CARE BY EACH PRODUCTION.

S-> 8A | 8
A-> 0B | 0
B-> 2C | 2
C-> 4D | 4
D-> 6E | 6
E-> S

QUESTION 9:-

The first digit can either be 3 or 7, second digit can either be 2 or 6, and so on...

S-> 3A | 7A | 3 | 7
A-> 2S | 6S | 2 | 6

If there is anything that you don not understand, then please mention it in the comments section.

Add a comment
Know the answer?
Add Answer to:
Design a regular grammar to generate the set of all even integers. Design a regular grammar...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT