100% found this document useful (1 vote)
80 views

Assignment TOC

Uploaded by

Anish
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
80 views

Assignment TOC

Uploaded by

Anish
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Theory of Computation (CEC15)

Assignment
1. Design a DFA to accept the string that always ends with 001011 over alphabet∑ = {0,1}.
2. Design a NFA that accepts those strings containing 1011 as a substring over alphabet∑ =
{0,1}.
3. Construct a DFA which accepts all strings over ∑={a,b} such that length of string is odd
and it starts with ‘ba’.
4. Design a DFA that accepts string made up of {0,1,2} i.e. ternary input alphabets and are
divisible by 4.
5. Design a DFA that accepts the strings over {0, 1}* for the language:
(i) L= {w: w has both an even number of 0’s and even number of 1’s}
(ii) L= {w: w has both an odd number of 0’s and even number of 1’s}
(iii)L= {w: ( |w0| mod 3 + |w1| mod 3 ) mod 3= 2} (|w0/1|: number of 0/1 in w)
(iv) L= {w: ( |w0| mod 3 - |w1| mod 3 ) mod 3= 0}
6. Design a Moore Machine to represent mod 3 value of a binary number. ∆={0,1,2} and
∑={0,1}.
7. Design a Mealy Machine that generates output ‘A’ if input string ends in ‘00’ and ‘B’ if it
ends in ‘11’ and ‘C’ otherwise. ∆={A,B,C} and ∑={0,1}.
8. Consider the following 𝜖-NDFA:
𝜖 a b c
→p {q,r} Φ {q} {r}
Q Φ {p} {r} {p,q}
*r Φ Φ Φ Φ
(i) Compute the 𝜖 -closure of each state.
(ii) Give the set of strings of length 3 or less accepted by the automata.
(iii)Convert the automata to a DFA.
9. Minimize the following DFA using subset construction method, having state 𝑞5 as final
state:
10. Consider following regular expression and find its equivalent minimized DFA
(10+(0+11)0*1
11. Consider L is a language over ∑={a,b} which contains all strings in which the third last
symbol is ‘b’.
a) Design an NFA for L.
b) Convert the designed NFA to DFA.
c) Give Regular Expression for L.

12. Find the CFG for the language


a) L={anbm| n+m is even}.
b) L= {ambn| m≠n}.

13. Let 𝐺 = ({𝑆, 𝐴1 , 𝐴2 }, {𝑎, 𝑏}, 𝑃, 𝑆) where P consists of 𝑆 → 𝑎𝐴1 𝐴2 𝑎, 𝐴1 → 𝑏𝑎𝐴1 𝐴2 𝑎, 𝐴2 →


𝐴1 𝑎𝑏, 𝑎𝐴1 → 𝑏𝑎𝑎, 𝑏𝐴2 𝑏 → 𝑎𝑏𝑎𝑏. Test whether 𝑤 = 𝑏𝑎𝑎𝑏𝑏𝑎𝑏𝑎𝑎𝑎𝑏𝑏𝑎𝑏𝑎
Is in L(G).
14. The following grammar generates the language consisting of all strings of even length :
𝑆 → 𝐴𝑆|∧, 𝐴 → 𝑎𝑎|𝑎𝑏| 𝑏𝑎 |𝑏𝑏.
Give left-most and right-most derivations for the following strings:
(i) bbbbbbba
(ii) baabab
(iii)aaabbb
15. Explain the Chomsky Hierarchy of languages. Determine the type of following grammar.
𝑆 → 𝑎𝐴𝑏|𝜀, 𝐴 → 𝑎𝐴|𝐴𝑏|𝑎|𝑏
16. Show that the following grammars are ambiguous :
a) S A|B
A aAb|ab
B aBb|ε

b) AaA|aAbA|ε
17. Convert the CFG into GNF:
𝑆 → 𝑎𝑆𝑏𝐴, 𝐴 → 𝑆𝑎 | 𝑎
18. Convert the given grammar G into CNF. G is 𝑆 → 𝐴𝐵𝐴, 𝐴 → 𝑎𝐴 |𝜀, 𝐵 → 𝑏𝐵 |𝜀.
19. Use the CFL pumping lemma to show that following language is not context free : 𝐿 =
{0𝑖 1𝑗 |𝑗 = 𝑖 2 }
20. Write down the steps required to convert CFG into Chomsky Normal Form. Consider the
following CFG and find its equivalent CNF and GNF.
𝐺: 𝑆 → 𝐴𝑆𝐵|𝜀
𝐴 → 𝑎𝐴𝑆|𝑎
𝐵 → 𝑆𝑏𝑆|𝐴|𝑏𝑏
21. What are useless symbols, unit productions and null productions in a grammar? Eliminate
unit productions from the following CFG :
𝐺: 𝐸 → 𝐸 + 𝑇|𝑇
𝑇 → 𝑇 ∗ 𝐹|𝐹
𝐹 → (𝐸) | 𝐼
𝐼 → 𝑎|𝑏|𝐼𝑎|𝐼𝑏|𝐼0 | 𝐼1
22. Give pushdown automata that recognize the following languages.
a) 𝐴 = {𝑤 ∈ {0,1}∗ | 𝑤 𝑐𝑜𝑛𝑡𝑎𝑖𝑛𝑠 𝑎𝑡𝑙𝑒𝑎𝑠𝑡 𝑡ℎ𝑟𝑒𝑒 1𝑠}
b) 𝐵 = {𝑤 ∈ {0,1}∗ | 𝑤 = 𝑤 𝑅 𝑎𝑛𝑑 𝑙𝑒𝑛𝑔𝑡ℎ 𝑜𝑓 𝑤 𝑖𝑠 𝑜𝑑𝑑}
c) 𝐶 = {𝑤 ∈ {0,1}∗ | 𝑤 = 𝑤 𝑅 }
d) 𝐷 = {𝑎𝑖 𝑏 𝑗 𝑐 𝑘 | 𝑖, 𝑗, 𝑘 ≥ 0, 𝑎𝑛𝑑 𝑖 = 𝑗 𝑜𝑟 𝑗 = 𝑘}
e) 𝐸 = {𝑎𝑖 𝑏 𝑗 𝑐 𝑘 | 𝑖, 𝑗, 𝑘 ≥ 0, 𝑎𝑛𝑑 𝑖 + 𝑗 = 𝑘}
f) 𝐹 = {𝑎2𝑛 𝑏 3𝑛 |𝑛 ≥ 0}
g) 𝐺 = {𝑎𝑚 𝑏 𝑛 𝑐 𝑛 |𝑚, 𝑛 ≥ 0
h) The language H of strings of properly balanced left and right brackets: every
leftbracket can be paired with a unique subsequent right bracket, and every
rightbracket can be paired with a unique preceding left bracket. Moreover, the
string between any such pair has the same property. For example,[][[[][]][]]∈A.
23. Write context free grammar for the corresponding PDA accepting language of question 1
(f), (g).
24. Write PDA transition rules for the following grammar:
a) 𝑆 → 𝑎𝐴𝑏|𝜀, 𝐴 → 𝑎𝐴|𝐴𝑏|𝑎|𝑏
b) 𝑆 → 𝐴𝐵𝐴, 𝐴 → 𝑎𝐴 |𝜀, 𝐵 → 𝑏𝐵 |𝜀
25. Design Turing machine for the language
𝐿 = {𝑎𝑛+2 𝑏 𝑛 |𝑛 > 0 }
26. Design transition diagram for the language 𝐿 = {𝑎𝑖 𝑏 𝑗 𝑐 𝑘 |𝑖, 𝑗 > 0 & 𝑘 = 𝑖 ∗ 𝑗}using Turing
Machine.
27. What do you understand by Instantaneous description of a Turing machine? Design a
Turing machine that computes the integer function f which multiplies two given positive
integers.
28. Design TM that accepts string of binary number whose decimal value is divisible by 3.
29. Design TM that accepts string of {0, 1} containing even number of 0 & odd number of
1’s.
30. Design TM that accepts language L={ww | w belongs to {a,b}*}.
31. Write short notes on the following:
(i) Universal Turing machine
(ii) Post correspondence problem

You might also like