


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The solutions to problem 1 to problem 4 from the cs 172, fall 2006 midterm 1 exam. The problems involve determining the regularity and context-free properties of certain languages using regular expressions, grammars, and automata.
Typology: Exams
1 / 4
This page cannot be seen from the preview
Don't miss anything!



For each of the following questions, state TRUE or FALSE. Justify your answer in brief, indicating only the “proof idea” or counterexample, drawing an annotated picture if needed.
(a) The regular expression 0(100 ∪ 010 ∪ 001)0 generates the language {w | w ∈ {0,1}* and w contains at least 2 0s and at most one 1}.
(b) The following grammar is unambiguous: ({S,A}, {0,1},R,S) where R has the rules S → 0A1 and A → ε | 0A1 | AA
(c) Let bi denote the standard binary encoding of non-negative integer i, without leading 0s. The language {bi | i is a multiple of 3} is regular.
Let L = { 1n^2^ | n a positive integer}. Show that L is not context free. Include all steps in your proof.
Define a FIFO automaton to be exactly like a pushdown automaton (PDA) except that it uses an unbounded queue instead of an unbounded stack. FIFO automata also use “push” and “pop” operations, only that “push” adds to the end of the queue, and “pop” removes from the front of the queue. The acceptance condition is the same as that of a PDA.
Define the language class Cfifo as the set {L | L is a language recognized by a FIFO automaton}.
Answer the following questions, justifying your answer (a proof idea/sketch will suffice, but it must precisely state the key insights):
(a) If A is a regular language, is A in Cfifo?
(b) Recall the context-free language B = {0n 1 n^ | n ≥ 0}. Is B in Cfifo?
(c) Recall the language D = {ww | w ∈ {0,1}*}. We showed in class that D is not context free. Is D in Cfifo?
(d) Using parts (a)-(c) and the course syllabus covered so far, what can you conclude about the subset relationships between Cfifo, the set of all regular languages Creg, and the set of all CFLs Ccf?