CS 172, Fall 2006 Midterm 1: Problem Set Solutions, Exams of Advanced Algorithms

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

2012/2013

Uploaded on 04/02/2013

sheba_876
sheba_876 🇵🇰

4.4

(8)

72 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 172, Fall 2006, Midterm 1, Seshia
Problem 1: [True or False, with justification] (30 points)
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 b
i
denote the standard binary encoding of non-negative integer i, without
leading 0s. The language {b
i
| i is a multiple of 3} is regular.
pf3
pf4

Partial preview of the text

Download CS 172, Fall 2006 Midterm 1: Problem Set Solutions and more Exams Advanced Algorithms in PDF only on Docsity!

CS 172, Fall 2006, Midterm 1, Seshia

Problem 1: [True or False, with justification] (30 points)

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?