CSCI 301 L29 Worksheet

Lecture 29 - Exercises

Part A - Chomsky Normal Form

Consider the following grammar in Chomsky Normal Form:

\(S_0 \rightarrow AM \mid SA \mid AS \mid NB \mid a\) \(S \rightarrow AM \mid SA \mid AS \mid NB \mid a\) \(A \rightarrow AM \mid SA \mid AS \mid NB \mid a \mid b\) \(B \rightarrow b\) \(M \rightarrow SA\) \(N \rightarrow a\)

  1. Perform a left-most derivation of 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\)?

  2. Here are the transition rules from the PDA conversion:

    Simulate this PDA as it processes the string \(bba\) from above, drawing the state of the tape and stack after each step of computation. Is this machine nondeterministic or deterministic?