Question

In: Computer Science

Convert the simple algebra below into Chomsky Normal Form (CNF), and then create a parse tree...

Convert the simple algebra below into Chomsky Normal Form (CNF), and then create a parse tree showing how the converted grammar could derive: x + y * z

E → E + T | T

T → T * F | F

F → (E) | x | y | z


Solutions

Expert Solution

Remove Units

»Remove E T , add E T * F |F

»Remove E F , add E (E) | x | y | z

»Remove T F , add T (E) | x | y | z

»The result:

»E E + T | T * F | (E) | x | y | z

»T T * F | (E) | x | y | z

»F (E) | x | y | z

Remove Mixed

»E E T+ T | T T* F | T(E T)| id

»T T T* F | T(E T)|  x | y | z

»F T(E T)| x | y | z

»T( (

» T) )

» T+ +

» T* *

Remove Long

»E E M2 | T M3 | T( M4 |x | y | z

»T T M3 | T(M4 | x | y | z

»F T( M4 | x | y | z

»M2 T+ T

»M3 T* F

»M4 E T)

» T( (

» T) )

» T+ +

» T* *

Add Epsilon:N/A

»E E M2 | T M3 | T( M4 | x | y | z

»T T M3 | T(M4 | x | y | z

»F T( M4 | x | y | z

»M2 T+ T

»M3 T* F

»M4 E T)

» T( (

» T))

» T+ +

» T* *

It derives expression 4+2*3 i.e. X+Y*Z


Related Solutions

Convert this into Chomsky normal form, where each rule is in the form: A --> BC...
Convert this into Chomsky normal form, where each rule is in the form: A --> BC or A --> a A --> A + B | B B --> B x C | C C --> (A) | 5
convert the following grammar to Chomsky Normal Form S -> D0S1 | 1 D -> F0D1...
convert the following grammar to Chomsky Normal Form S -> D0S1 | 1 D -> F0D1 | 0 | e | FG F -> SF | DD | S G -> GK | DG
Create an example of a table that violates first normal form. Create an example of a...
Create an example of a table that violates first normal form. Create an example of a table that is in first normal form but violates second normal form. Create an example of a table that is in second normal form but violates third normal form. Please use own table or no plagiarism please.Thank you.
Is there a simple way to create a username and password for a registeration form? The...
Is there a simple way to create a username and password for a registeration form? The username should be between 4 and 20 characters. The password should be between 4 and 12 characters, contain at least one digit, and contain at least one uppercase and one lowercase character. Select four special characters and require that the password contain at least one of them.
Convert the logical statement ~(P || ~R) || (Q -> R) to conjunctive normal form. Please...
Convert the logical statement ~(P || ~R) || (Q -> R) to conjunctive normal form. Please explain the steps!!
Consider the following relation and convert to the normal form indicated. Make sure your Primary Key...
Consider the following relation and convert to the normal form indicated. Make sure your Primary Key and its attribute(s) is/are underlined for full credit. Also indicate foreign keys using (FK) if any. 0NF: ORDER[order_num, date, SSN, cust_name, phone, email, (SKU, item_name, price)] Notes:An order has only one customer, but a customer can place many orders. Each order can have multiple items.   1NF: 2NF: 3NF:
JAVA PROGRAM Create a Binary Search Tree with the following elements in the order mentioned below:...
JAVA PROGRAM Create a Binary Search Tree with the following elements in the order mentioned below: 5, 85, 89, 3, 2, 8, 65, 92 Print the Pre-order of this tree Print the height and the balance factor of the nodes in the order they were inserted (5, 85, 89, 3, 2, 8, 65, 92) in the form of a table with three columns and 9 rows. Use column headers “Node”, “Height”, and “Balance Factor” for the three columns respectively. Use...
Create a Binary Search Tree with the following elements in the order mentioned below: 5, 85,...
Create a Binary Search Tree with the following elements in the order mentioned below: 5, 85, 89, 3, 2, 8, 65, 92 Print the Pre-order of this tree Print the height and the balance factor of the nodes in the order they were inserted (5, 85, 89, 3, 2, 8, 65, 92) in the form of a table with three columns and 9 rows. Use column headers “Node”, “Height”, and “Balance Factor” for the three columns respectively. Use the following...
using PDO, MYSQL, and Html, how can i create a simple registration and login form for...
using PDO, MYSQL, and Html, how can i create a simple registration and login form for cPanel?
Using PHP and MySQL Create a simple web form with at least 5 fields Include validation...
Using PHP and MySQL Create a simple web form with at least 5 fields Include validation and error messages Create a MySQL Database Create a table to store submissions from the form Only insert new data into the database when all validation is passed Use PHP to create an HTML table showing all the content of the database   New submissions should appear in table
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT