CSCI 301 L33 Worksheet

Lecture 33 - Exercises

Part A - Chomsky Normal Form

Consider the following grammar in Chomsky Normal Form:

\(S_0 \rightarrow AM \mid AS \mid SA \mid NB \mid a\)

\(S \rightarrow AM \mid AS \mid SA \mid NB \mid a\)

\(A \rightarrow AM \mid AS \mid SA \mid NB \mid a \mid b\)

\(B \rightarrow b\)

\(M \rightarrow SA\)

\(N \rightarrow a\)

  1. Derive the string \(bba\). How many steps was your derivation?
  2. How many steps is any derivation for a string with length \(n\)?

Part B - CFG to PDA Conversion

  1. Suppose the above grammar also had the production \(S_0 \rightarrow \epsilon\), which is only allowed in CNF because \(S_0\) is the start symbol. What would we need to add to the transition function of the PDA to make it accept the string \(\epsilon\)?