Question

I have below questions with answer! what if we get different question: Write a CFG without...

I have below questions with answer! what if we get different question:

Write a CFG without empty rules that generates the language:
L = strings from (a ∪ b)*c* where the number of a's
and b's together is equal to the number of c's.

Answer:
S → Asc | ε
A → a | b

==================================================

Write a CFG without empty rules that generates the language:
L = strings from (ab ∪ cb)*c* where the number of a's
and b's together is equal to the number of c's.

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

Always it is easy to construct a grammar if you imagine the basic strings [LEAST LENGTH STRINGS] produced by the grammar and then proceed.

Add a comment
Know the answer?
Add Answer to:
I have below questions with answer! what if we get different question: Write a CFG without...
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
  • Give a context free grammar for the language L where L = {a"bam I n>:O and...

    Give a context free grammar for the language L where L = {a"bam I n>:O and there exists k>-o such that m=2"k+n) 3. Give a nondeterministic pushdown automata that recognizes the set of strings in L from question 3 above. Acceptance should be by accept state. 4. 5 Give a context-free grammar for the set (abc il j or j -k) ie, the set of strings of a's followed by b's followed by c's, such that there are either a...

  • 1. Give a context-free grammar for the set BAL of balanced strings of delimiters of three...

    1. Give a context-free grammar for the set BAL of balanced strings of delimiters of three types (), and . For example, (OOis in BAL but [) is not. Give a nondeterministic pushdown automata that recognizes the set of strings in BAL as defined in problem 1 above. Acceptance should be by accept state. 2. Give a context free grammar for the language L where L-(a"b'am I n>-o and there exists k>-o such that m-2*ktn) 3. Give a nondeterministic pushdown...

  • For each of the languages listed below, give a regular expression that generates the lan- guage....

    For each of the languages listed below, give a regular expression that generates the lan- guage. Briefly justify your answer. (a) The set of strings over (a, b such that any a in the string is followed by an odd number of b's. Examples: bbbab E L, but abb f L. (b) The set of strings over fa, b in which there is an a in every even position and the total number of b's is odd, where the first...

  • Please Answer Question#02 Solution of Question 1 is attached. Solution of Questions #01 Please do Questions...

    Please Answer Question#02 Solution of Question 1 is attached. Solution of Questions #01 Please do Questions #01 As soon as possible. = {a, b} will be used for all of the following exercises. The alphabet 1. Give regular expressions which exactly define the following languages. [7 marks] (a) L1 which has exactly one b but any number of as. (b) L2 which has an even number of as and an even number of bs. [7 marks] (c) L3 which contains...

  • 7. Lexical analyzer, is the first phase in compiler, Of what use is this to the...

    7. Lexical analyzer, is the first phase in compiler, Of what use is this to the whole compilation and 14 marks) what are the formal concepts involved ? 8. Describe this language using a Regular Expression: all strings beginning with a digit, followed 13 marks] by either a or b, and ending with an non-vowel uppercase letter 9. Write a context free granimar for the strings that consist of equal number of a's followed by equal number of b's. Attempt...

  • 3 points) Question Three Consider the context-free grammar S >SS+1 SS 1a and the string aa...

    3 points) Question Three Consider the context-free grammar S >SS+1 SS 1a and the string aa Give a leftmost derivation for the string. 3 points) (4 poiots) (5 points) (3 points) sECTION IWOLAttcmpt.any 3.(or 2) questions from this.scction Suppose we have two tokens: (1) the keyword if, and (2) id-entifiers, which are strings of letters other than if. Show the DFA for these tokens. Give a nightmost derivation for the string. Give a parse tree for the string i) Is...

  • please write clearly. thanks Part I. For questions 1-10, use only the sum, product and division...

    please write clearly. thanks Part I. For questions 1-10, use only the sum, product and division rules or a tree diagram to solve the problems. 1. Six different airlines fly from New York to Denver and seven fly from Denver to San Francisco. How many different pairs of airlines can you choose on which to book a grip from New York to San Francisco via Denver? 2. How many bit strings of length ten both begin and end with a...

  • Needhelp in below projects Legal Aspects of Business Answer any one of the questions 1 and...

    Needhelp in below projects Legal Aspects of Business Answer any one of the questions 1 and 2. Question number three and four is compulsory. 1.”All agreements are not contracts but all contracts are agreements.” Discuss the statement explaining the essential elements of a valid contract. 2.What is an “offer”? When is it complete? State the rules of a valid offer. {15 marks} 3. Attempt the following problems, giving reasons:- A] Over a cup of coffee in a restaurant, A invites...

  • Assume that we have three independent observations: where Xi ~ Binomial(n 7,p) for i E { 1.2.3). The value of p E (0, 1) is not known. When we have observations like this from different, independent...

    Assume that we have three independent observations: where Xi ~ Binomial(n 7,p) for i E { 1.2.3). The value of p E (0, 1) is not known. When we have observations like this from different, independent ran- dom variables, we can find joint probabilities by multiplying together th ndividual probabilities. For example This should remind you the discussion on statistical independence of random variables that can be found in the course book (see page 22) Answer the following questions a...

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
ADVERTISEMENT