Question

In: Computer Science

- Given this Grammar (we substitute one element per line) (rules#) One substitution must be permitted...

- Given this Grammar (we substitute one element per line)
(rules#) One substitution must be permitted by one rule
(rules#)
<S> -> a<S>c<B> | <A> | b (1,2,3)
<A> -> c<A> | c (4,5)
<B> -> d | <A> (6,7)

- Which of the following sentences are in the language generated by the Grammar ?

sentences
a- abcd
b- acccbd
c- acccbcc
d- acd
e- accc

(accc sentence can be left_derived by using some grammar rules) :
The e- Solution is given here as a successful left Derivation:

Try to derive more from the given sentences.

(rule#)
<S> -> a <S> c <B> (1)
-> a <A> c <B> (2)
a <A> c <A> (7)
a c c <A> (5)

-> a c c c (5)


A successful derivation leads to terminals only;
Compilers approve <accc> this given language syntax that is defined by this given grammar.

Solutions

Expert Solution

The production rules are as follows

<S> -> a <S> c <B> | <A> | b (1, 2, 3)
<A> -> c <A> | c (4, 5)
<B> -> d | <A> (6, 7)

(a) abcd

<S> -> a <S> c <B> (1)

-> a b c <B> (3)

-> a b c d   (6)

(b) acccbd

It cannot be derived from the given production rules as shown below

<S> -> a <S> c <B> (1)

Now we try to generate the three c's using the sentential form given below

-> a <A> c <B> (2)

We can know see that we cannot generate 'b' as <S> is lost and cannot be re-generated.

Hence, the given string cannot be generated.

(c) acccbcc

It cannot be derived from the given production rules as shown below

<S> -> a <S> c <B> (1)

Now we try to generate the sentential form given below for generating three c's after 'a'

-> a <A> c <B> (2)

We can know see that we cannot generate 'b' as <S> is lost and cannot be re-generated.

Hence, the given string cannot be generated.

(d) acd

It cannot be derived from the given production rules as ε epsilon (ε is epsilon used to represent null string. In some books null string is also denoted by λ (lambda) ) is not generated by <S>. The smallest length string that can be generated is "a b c d".

(e) accc

<S>  -> a <S> c <B> (1)

-> a <A> c <B> (2)

-> a <A> c <A> (7)

-> a c c <A> (5)

-> a c c c   (5)

Hence only the sentences in part (a) and (e) are there in the given language.


Related Solutions

#1 We are given the grammar rules A ➝ F B E B ➝ A C...
#1 We are given the grammar rules A ➝ F B E B ➝ A C These rules are only some of the rules of a larger grammar G, but we are not given the remaining rules of G. We are told that A is the start symbol of G and that the following holds: {ε, c, d} ⊆ FIRST(C) {ε, e} ⊆ FIRST(E) {ε, f, g} ⊆ FIRST(F) Recall that end of file is denoted EOF. The symbol ⊆...
you are given one atom of the element 11-B5-. How many protons are in this element?...
you are given one atom of the element 11-B5-. How many protons are in this element? How many neutrons are in the element How many electrons are in the element
4. How can you tell the blue line emitted from one element as compared to a...
4. How can you tell the blue line emitted from one element as compared to a blue line emitted from a second element?
What is the correct line of thinking in dealing with a statics problem where one must...
What is the correct line of thinking in dealing with a statics problem where one must determine the resultant force from multiple vectors using a unit triangle instead of cos and sin; ie. how do you use a unit triangle?
Why must we account for deferred tax in financial statements? (as per IFRS)
Why must we account for deferred tax in financial statements? (as per IFRS)
Suppose we replace Incidence Axiom 4 with the following: Given any line, there are at least...
Suppose we replace Incidence Axiom 4 with the following: Given any line, there are at least three distinct points that lie on it. What is the smallest number of points in a model for this geometry? More precisely, find a number n such that every model has at least n points and there is at least one model that has only n points, and explain why your answer is correct.
write one paragraph, If we must borrow significant amounts ofmoney, how do we account for...
write one paragraph, If we must borrow significant amounts of money, how do we account for the cost of the loan in the pricing of the product (pick and place robot) ? What economic considerations arose in pick and place ro
1. We learn that opportunity cost can be defined as what must be given up to...
1. We learn that opportunity cost can be defined as what must be given up to obtain something else. Can you think of one example of an opportunity cost you came across this past week? Explain how this concept played a role in your decision making. 2. A budget constraint indicates possible combinations of two goods affordable within a certain budget. Can you relate this concept to your own life?
Implement a function that reads numbers in from a file with one number per line and...
Implement a function that reads numbers in from a file with one number per line and outputs all the possible sums that can be formed by subsets of the numbers. For instance, if the numbers in the file are 1 2 4, then the output would be 0, 1, 2, 4, 3, 5, 6, 7. Note that 0 is in the output because it uses none of the numbers, while 7 is the sum of all of the numbers. //...
1. Under IFRS, a discontinued operation must be a: Select one: a. Product line. b. Cash...
1. Under IFRS, a discontinued operation must be a: Select one: a. Product line. b. Cash Generating Unit (CGU) c. Product line or Geographic segment. d. Geographic segment. 2. A company is preparing its bank reconciliation for December 31, 2004 (end of the reporting period). The following verified data are available: Based on the above data only, the amount for the December 2004 bank reconciliation Deposits in Transit is: Select one: a. Insufficient Information Provided b. 17810 c. 3070 d....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT