World's most popular travel blog for travel bloggers.

[Solved]: Can a CFG end have a non-terminal symbol in the middle of it?

, , No Comments
Problem Detail: 

What is the correct way to write a CFG?

A -> B C' E C' -> C C' -> null 

or

A -> B C' C' -> C E C' -> E 
Asked By : Badger Cat

Answered By : usul

Both of those are valid context-free grammars. (For the same language.) The requirement for a context-free grammar is just that the left side of the production must have exactly one non-terminal, which both of them satisfy. (Usually, to make this more clear, we'd have a convention like non-terminals are uppercase and variables are lower-case, and we'd specify the start symbol. But it looks clear that you have $A$ and $C'$ as nonterminals and the rest terminals, with $A$ being the start symbol.)

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/9495

0 comments:

Post a Comment

Let us know your responses and feedback