Академический Документы
Профессиональный Документы
Культура Документы
Homework 1 Solutions
Instructor: Prof. Wen-Guey Tzeng Scribe: Amir Rezapour
2. Let L = {ab, aa, baa}. Which of the following strings are in L∗ : abaabaaabaa,
aaaabaaaa, baaaaabaaaab, baaaaabaa? Which strings are in L4 ?
Answer.
aa aab aa aa , baa aa ab aa 2
3. For Σ = {a, b}, construct dfa’s that accept the sets consisting of all the strings with
at least two a’s.
Answer.
1-1
5. Find a dfa for L = {w : (na (w) − nb (w)) mod 3 = 0}, where Σ = {a, b}. Answer.
7. Construct a dfa for all strings on {0, 1} of length five or more in which the third
symbol from the right end is different from the leftmost symbol.
Answer.
1-2
8. Let L be the language accepted by the automaton in Figure 1. Find a dfa that accepts
the language L2 − L.
Figure 1: Dfa
Answer.
Figure 2: Question 8
Figure 3: Nfa
Answer.
δ ∗ (q0 , 1011) → {q2 }
δ ∗ (q1 , 01) → {q1 }
2
10. Design an nfa with no more than five states for the set {ababn : n ≥ 0}∪{aban : n ≥ 0}.
Answer.
2
1-3
Figure 4: Nfa
11. Find an nfa with no more than three states that accepts the language L = {an : n ≥
1} ∪ {bm ak : m ≥ 0, k ≥ 0}.
Answer.
Figure 5: Nfa
δ(q0 , a) = {q0 , q1 }
δ(q1 , b) = {q1 , q2 }
(1)
δ(q2 , a) = {q2 }
δ(q0 , λ) = {q2 }
with initial state q0 and the final state q2 into an equivalent dfa.
Answer.
13. Prove that for every nfa with an arbitrary number of final states there is an equivalent
nfa with only one final state. Can we make a similar claim for dfa’s?
Answer. We can create one final state qf inal and connect nfa’s final states to the
qf inal and set them to non-final state.
Since λ transition doesn’t exist in dfa, therefore we cannot always find the correspond-
ing dfa with only one final state. 2
1-4
14. Show that if L is regular, so is LR .
Answer.
Informally, the following procedure shows that we can always construct a finite ac-
cepter MLR that accepts LR for a given finite accepter ML that accepts L.
Formally, let ML = (QL , Σ, δL , q0 , FL ) be an NFA that accepts L. The NFA MLR below
accepts LR .
15. From a language L, we create a new language, choplef t(L), by removing the leftmost
symbol of every string in L. Specifically,
1-5
1-6