Question

Given the following grammar with start symbol : ?: ? → b? | a? ? →...

Given the following grammar with start symbol :

?: ? → b? | a?

? → a? | ε

a) Give two strings derived from this grammar and their corresponding derivations. (Please mention the derivation as well).

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

Answer

bba and aaaa are two strings that can be derived with this grammar

1)  bba
Derivation:
-------------
S -> bS
-> bbS
-> bbaX
-> bbaε
-> bba

2)  aaaa
Derivation:
-------------
S -> aX
-> aaX
-> aaaX
-> aaaaX
-> aaaaε
-> aaaa
Add a comment
Know the answer?
Add Answer to:
Given the following grammar with start symbol : ?: ? → b? | a? ? →...
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
  • Consider the following context-free grammar with terminals {a, b, c, d} and start symbol S. S...

    Consider the following context-free grammar with terminals {a, b, c, d} and start symbol S. S → W | X | Y | Z W → AW D | X | Y | Z X → BXD | Z Y → AY C | Z Z → BZC | ε A → a B → b C → c D → d (a) Give a derivation tree with input string: aaaabccddd (b) What language does this CFG recognize? Give a...

  • Consider the following regular grammar with start symbol S and terminals {x, y}. S → xS...

    Consider the following regular grammar with start symbol S and terminals {x, y}. S → xS S → yX S → yY X → xX X → yS Y → xY Y → λ List four strings, each of length less than 4, accepted by this grammar. (Include ε if it is accepted.) List four strings, each of length less than 4, not accepted by this grammar. (Include ε if it is not accepted.) In English, describe the language represented...

  • IN HASKELL Consider a context-free grammar with nonterminal symbols: sentence (the start symbol), noun-phrase, verb-phrase, article,...

    IN HASKELL Consider a context-free grammar with nonterminal symbols: sentence (the start symbol), noun-phrase, verb-phrase, article, noun, and verb; terminal symbols: "." (period), "a", "the", "girl", "dog", "sees", and "pets"; and the following rules: sentence = noun-phrase verb-phrase "." . noun-phrase = article noun . article = "a" | "the" . noun = "girl" | "dog" . verb-phrase = verb noun-phrase . verb = "sees" | "pets" . a. Give a left-most derivation of the sentence: a girl pets the...

  • (a0Give the derivations and parse trees for the following strings using the grammar given below: •...

    (a0Give the derivations and parse trees for the following strings using the grammar given below: • abba • babab (b)   Give the derivations and parse trees for the following strings using the grammar given below: • a cat napped • a cat barked P={ <sentence> → <article><noun><verb> <article> → "a" <article> → "the" <noun → "dog" <noun> → "cat" <verb> → "barked" <verb> → "napped" }

  • 1. For the following grammar: a) Give an example of a string accepted by the grammar. b) Give an ...

    Theory of Computation need ASAP 2-3 hours 1. For the following grammar: a) Give an example of a string accepted by the grammar. b) Give an example of a string not accepted by the grammar. c) Describe the language produced by the grammar. 2. Using the following grammar find a derivation for the string: 0001112 A0A1le C 0C2 | D Create a grammar for the language described by the following RE: Create a grammar for the following language: For the...

  • Consider the following grammar (S, A, B, and C are nonterminal symbols; S is the start...

    Consider the following grammar (S, A, B, and C are nonterminal symbols; S is the start symbol; 0 and 1 are terminal symbols): S → AA A → BCB B → B0 | B1 | 0 | 1 C → 00 | 11 Which of the following sentences are in the language generated by the grammar? Show derivations for the sentences that can be generated. If a sentence cannot be generated by the grammar, explain why. a) 10010001 b) 01101101...

  • Consider the following grammar: (//some alternative rules are listed on separate lines without using symbol |):...

    Consider the following grammar: (//some alternative rules are listed on separate lines without using symbol |): stmt −> assignment −> subr call assignment −> id := expr subr call −> id ( arg list ) expr −> primary expr tail expr tail −> op expr −> ε primary −> id −> subr call −> ( expr ) op −> + | - | * | / arg list −> expr args tail args tail −> , arg list −> ε...

  • 1.)    Consider the following grammar in which S, A, and B are nonterminal symbols and S...

    1.)    Consider the following grammar in which S, A, and B are nonterminal symbols and S is the start symbol. S → 1A | 0B A → A0 | 1B B → 10A| 1 Show that the grammar is ambiguous by showing two parse trees for the sentence 1110110 using leftmost derivation.

  • 1. (15 pts) Consider the following BNF grammar: For each of the strings below, indicate whether...

    1. (15 pts) Consider the following BNF grammar: For each of the strings below, indicate whether or not the string can be derived from the grammar. ?f so, provide a derivation. (a) (5 pts) aabccd (b) (5 pts) accbcc (c) (5 pts) acccce

  • Given the following ambiguous context free grammar (3x20) 1. (a) Explain why the grammar is ambiguous...

    Given the following ambiguous context free grammar (3x20) 1. (a) Explain why the grammar is ambiguous (b) Find an equivalent unambiguous context-free grammar. (c) Give the unique leftmost derivation and derivation tree for the string s generated from the unambiguous grammar above. 2. Construct non-deterministic pushdown automata to accept the following language (20) 3. Convert the following CFG into an cquivalent CFG in Chomsky Normal Form (CNF) (20)-

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