Midterm 1 e

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

CS/ECE 374 A Midterm 1 (version ") Questions Spring 2018

Write your answers in the separate answer booklet.


Please return this question sheet and your cheat sheet with your answers.

1. For each statement below, check “Yes” if the statement is always true and “No” otherwise.
Each correct answer is worth +1 point; each incorrect answer is worth −½ point; checking
“I don’t know” is worth +¼ point; and flipping a coin is (on average) worth +¼ point. You
do not need to prove your answer is correct.
Read each statement very carefully. Some of these are deliberately subtle.

(a) No infinite language is regular.


(b) If L is regular, then for every string w ∈ L, there is a DFA that rejects w.
(c) If L is context-free and L has a finite fooling set, then L is not regular.
(d) If L is regular and L 0 ∩ L = ∅, then L 0 is not regular.
(e) The language {0i 1 j 0k | i + j + k ≥ 374} is regular.
(f) The language {0i 1 j 0k | i + j − k ≥ 374} is regular.
(g) Let M = (Q, {0, 1}, s, A, δ) be an arbitrary DFA, and let M 0 = (Q, {0, 1}, s, A, δ0 ) be
the DFA obtained from M by changing every 0-transition into a 1-transition and
vice versa. More formally, M and M 0 have the same states, input alphabet, starting
state, and accepting states, but δ0 (q, 0) = δ(q, 1) and δ0 (q, 1) = δ(q, 0). Then
L(M ) ∪ L(M 0 ) = {0, 1}∗ .
(h) Let M = (Q, Σ, s, A, δ) be an arbitrary NFA, and M 0 = (Q0 , Σ, s, A0 , δ0 ) be any NFA
obtained from M by deleting some subset of the states. More formally, we have
Q0 ⊆ Q, A0 = A ∩ Q0 , and δ0 (q, a) = δ(q, a) ∩ Q0 for all q ∈ Q0 . Then L(M 0 ) ⊆ L(M ).
(i) For every non-regular language L, the language 0|w| w ∈ L is also non-regular.


(j) For every context-free language L, the language 0|w| w ∈ L is also context-free.


2. For any language L, define

StripFinal0s(L) = {w | w0n ∈ L for some n ≥ 0}

Less formally, StripFinal0s(L) is the set of all strings obtained by stripping any number of
final 0s from strings in L. For example, if L is the one-string language {01101000}, then

StripFinal0s(L) = {01101, 011010, 0110100, 01101000} .

Prove that if L is a regular language, then StripFinal0s(L) is also a regular language.

1
CS/ECE 374 A Midterm 1 (version ") Questions Spring 2018

3. For each of the following languages L over the alphabet Σ = {0, 1}, give a regular expression
that represents L and describe a DFA that recognizes L.

0 w1 n ≥ 1 and w ∈ Σ+
 n n
(a)
(b) All strings in 0∗ 1∗ 0∗ whose length is even.

4. The parity of a bit-string is 0 if the number of 1 bits is even, and 1 if the number of 1 bits
is odd. For example:

parity(") = 0 parity(0010100) = 0 parity(00101110100) = 1

(a) Give a self-contained, formal, recursive definition of the parity function. In particular,
do not refer to # or other functions defined in class.
(b) Let L be an arbitrary regular language. Prove that the language OddParity(L) :=
{w ∈ L | parity(w) = 1} is also regular.
(c) Let L be an arbitrary regular language. Prove that the language AddParity(L) :=
{parity(w) · w | w ∈ L} is also regular. For example, if L contains the strings 01110
and 01100, then AddParity(L) contains the strings 101110 and 001100.


5. Let L be the language 0i 1 j 0k 2i = k or i = 2k .

(a) Prove that L is not a regular language.


(b) Describe a context-free grammar for L.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy