Given a grammar in Chomsky Normal Form and several strings, determine whether or not each of the strings given is part of the grammar described. To simplify matters, the alphabet for each problem will be the lowercase letters, and the set of variables will be all capital letters. The start symbol will always be S. Epsilon, the empty string, vill be represented by the character @'.
Given a grammar in Chomsky Normal Form and several strings, determine whether or not each of the strings given is part of the grammar described. To simplify matters, the alphabet for each problem will be the lowercase letters, and the set of variables will be all capital letters. The start symbol will always be S. Epsilon, the empty string, vill be represented by the character @'.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
java language
There is one change. The document says that there is an input / output file required, but actually the input / output has to be read in from terminal, using standard input and output. And also it must be a key to compile on terminal.

Transcribed Image Text:The Problem
Given a grammar in Chomsky Normal Form and several strings, determine whether or not each
of the strings given is part of the grammar described.
To simplify matters, the alphabet for each problem will be the lowercase letters, and the set of
variables will be all capital letters. The start symbol will always be S. Epsilon, the empty string,
will be represented by the character @'.
Input File Format (chomsky.in)
The first line of the input file will contain a single positive integer, n (n < 100), representing the
number of grammars that are going to be described in the file.
For each grammar, the first line will have a single positive integer, v (v < 27), representing the
number of variables. The next v lines will contain the rules for each variable.
For each of these lines, the first token on the line will be a positive integer r (r < 100),
representing the number rules for the variable described on that line. The second token on the
line will be the variable for the line, a single capital letter. After the variable, there will be r
tokens that follow. Each token will either be two capital letters (variables), or a single lower case
letter (terminal). For the line with 'S’, the character @’ may be present to represent epsilon.
Note: The start variable is always S, but it may appear on any of these v lines.
On the next line there will be a single positive integer, s, representing the number of strings to
test. The next s lines will contain one string of lowercase letters or @’ each. Each string will be
of length 100 or less.

Transcribed Image Text:Sample Input
3
2 S AB BB
ЗА ВВ а b
2 вьс
bcb
2 S AA @
ЗА АА х у
3
asd
YYYY
Sample Output
Grammar #1:
bcb: YES
c: NO
Grammar #2:
@: YES
asd: NO
УУуу: ҮES
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY