COMS W3261
Computer Science Theory
Homework Assignment #2
October 1, 2012
Due in class 1:10pm, October 15, 2012



  1. Consider the grammar G:
    S → a S b S | b S a S | ε
    1. Describe in English the language generated by G. Prove that G generates precisely this language.
    2. Is the language generated by G regular? Prove your answer.

  2. Put the grammar G in question (1) into Chomsky Normal Form. Use the Cocke-Younger-Kasami algorithm to parse the sentence abab according to your CNF grammar. Display the CYK table constructed by the CYK algorithm and show how all parse trees for this sentence can be reconstructed from the CYK table.

  3. From the grammar G in question (1), construct a pushdown automaton that accepts L(G) by empty stack. Show all sequences of moves that your PDA can make to accept the input string abab.

  4. From your PDA in question (3), construct an equivalent context-free grammar. Show a parse tree for the input string abab according to your grammar.

  5. Consider the language L consisting of all strings of a's and b's that are even-length palindromes with the same number of a's as b's. If L is context free, construct a CFG for L and prove that your grammar generates precisely this language. If L is not context free, use the pumping lemma for context-free languages to prove that L is not context free.