Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

First, simplify the context-free grammar, and then convert the grammar to Chomsky normal form and Greibach normal form. 1) S --> AB | aB A

First, simplify the context-free grammar, and then convert the grammar to Chomsky normal form and Greibach normal form.

1)

S --> AB | aB

A --> abb |

B --> bbA

2)

S --> baAB

A --> bAB |

B --> BAa | A |

Supplemental Information:

a) Algorithm to Convert into Chomsky Normal Form

Step 1 If the start symbol S occurs on some right side, create a new start symbol S and a new production S S.

Step 2 Remove Null productions. (Using the Null production removal algorithm discussed earlier)

Step 3 Remove unit productions. (Using the Unit production removal algorithm discussed earlier)

Step 4 Replace each production A B1Bn where n > 2 with A B1C where C B2 Bn. Repeat this step for all productions having two or more symbols in the right side.

Step 5 If the right side of any production is in the form A aB where a is a terminal and A, B are non-terminal, then the production is replaced by A XB and X a. Repeat this step for every production which is in the form A aB.

b) Algorithm to Convert a CFG into Greibach Normal Form

Step 1 If the start symbol S occurs on some right side, create a new start symbol S and a new production S S.

Step 2 Remove Null productions. (Using the Null production removal algorithm discussed earlier)

Step 3 Remove unit productions. (Using the Unit production removal algorithm discussed earlier)

Step 4 Remove all direct and indirect left-recursion.

Step 5 Do proper substitutions of productions to convert it into the proper form of GNF.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions

Question

2. What do you believe is at the root of the problem?

Answered: 1 week ago