Question

In: Computer Science

We are using javaCC notation.This is the full question Given the following grammar: String ::= "A"...

We are using javaCC notation.This is the full question

Given the following grammar:

  • String ::= "A" ( "B" | T | V )+
  • T ::= ("X" T ) | "Y"
  • V ::= ( "C" | "D" )*

Which of the following strings are correct according to this grammar?

Group of answer choices

A C C D X X Y

X X Y

A B C D

A X

A B C D

A C D C

A B C D X Y

A X X X

A X Y X C D

A B X X Y

B C D

A

B X X Y

Solutions

Expert Solution

According to the given gramer

1.The string must start with "A" and follows "B" or "c" or "D" or "x" or "Y"

2.If we see Grammer T it should have either "X" and again calling T or only "Y".This shows that T always ends with "Y". that is If we have "X" in the string it should have any number of "X" and should ends with Y:
eg:XY,XXY,XXXXXY etx they are correct strings
X,XX,XYX etc which ends with X are incorrect strings.

So by considering the about two points

1. ACCDXXY is a correct string.
3.ABCD is correct string
4.ACDC is correct string.
5.ABCDXY is correct string
8.ABXXY is correct string.
10.A is correct string. There("B"|T|V)+ "+" represents either 0 or n times.

2.XXY is incorrect because of reason 1
6.AXXX is incorrect string because of reason 2
7.AXYXCD is incorrect string because of reason 2
9.BCD is incorrect string because of reason 1
11.BXXY is incorrect string because of reason 1


Related Solutions

Please answer all question using a full paragraph, watch you grammar and syntax. a. What is...
Please answer all question using a full paragraph, watch you grammar and syntax. a. What is trend in investor ratios of Walgreens - use ratios in the answer? (please use at least three sentences. b. What is trend in investors ratios of CVS - use ratios in the answer? (please use at least three sentences) c. Which company has had the better investor ration over the last the years - explain using ratios? ( please use at least three sentences)...
Please answer all question using a full paragraph, watch you grammar and syntax. a. What is...
Please answer all question using a full paragraph, watch you grammar and syntax. a. What is trend in Long Term Debt Paying ability ratios of CVS over the last three years - Explain using ratios and three sentences? b. What is trend in Long Term Debt Paying Ability ratios of Walgreens over the last three years - Explain using rations and three sentences? c. Which company has had better Long Term Debt Paying baility ratios over the last 3 years?...
Answer each of the 4 part question using full sentences and good grammar. Use your own...
Answer each of the 4 part question using full sentences and good grammar. Use your own words. A. List the conditions necessary for the CLT to hold. Make sure to list alternative conditions for when we know the population distribution is normal vs. when we don't know what the population distribution is, and the when the sample size is barely over 30 vs. when it's very large. B. Explain, in plain English, the difference between standard error and margin of...
#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 ⊆...
Ex#3: Give a string of lengths, 4, 6, 8 generated by the following grammar G =...
Ex#3: Give a string of lengths, 4, 6, 8 generated by the following grammar G = (V, T, S. P). S → 0S S --> 0S1S S --> λ
- 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...
QUESTION 60 Given the following Product structure: struct Product {     string name;     double price;...
QUESTION 60 Given the following Product structure: struct Product {     string name;     double price;     int quantity;     bool equals(const Product&); }; how would you define the equals function so two products are equal if their names and prices are equal? a. bool equals(const Product& to_compare) {     return (name == to_compare.name && price == to_compare.price); } b. bool Product::equals(const Product& to_compare) {     return (name == to_compare.name || price == to_compare.price); } c. bool equals(const Product& to_compare)...
a) Discuss two basic forms of compression. Given the following data string, present the result using...
a) Discuss two basic forms of compression. Given the following data string, present the result using run-length encoding. By what percentage is the data compressed? 0000011000000001000000000100001100000000 [5 Marks] b) Sam wants to send 2000 8-bit characters of data. Find the total number of bits he will transmit using asynchronous transmission. Now, if he decides to use the synchronous connection, how many bits will be transferred if 1000 characters fit within one synchronous transmission frame? [5 M
a) Discuss two basic forms of compression. Given the following data string, present the result using...
a) Discuss two basic forms of compression. Given the following data string, present the result using run-length encoding. By what percentage is the data compressed? 0000011000000001000000000100001100000000 [5 Marks] b) Sam wants to send 2000 8-bit characters of data. Find the total number of bits he will transmit using asynchronous transmission. Now, if he decides to use the synchronous connection, how many bits will be transferred if 1000 characters fit within one synchronous transmission frame?
Given a parentheses string s, compute the score of the string based on the following rule:...
Given a parentheses string s, compute the score of the string based on the following rule: • If s is not balanced, the score is 0. • () has score 1. • AB has score A + B, where A and B are balanced parentheses strings. • (A) has score 2 * A, where A is a balanced parentheses string. A balanced string satisfies the following requirements: • The number of ‘(’ equals the number of ‘)’ in the string....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT