Uploaded by yaswanthvuyyuru

TOC - E

advertisement
Department of Computer Science and Engineering
Year & Section: II & E
Academic Year: 2022-23
Subject: Theory of Computation
1. For each of the following languages, construct an DFA and NFA, that accepts the language. In
all cases, the alphabet is {0,1}.
• {๐‘ค โˆถ ๐‘ค contains the substring 1011}.
• {๐‘ค โˆถ ๐‘ค contains at least two 1s and at most two 0s}.
• {๐‘ค โˆถ ๐‘ค contains an odd number of 1s or exactly two 0s}.
• {๐‘ค โˆถ ๐‘ค begins with 1 and ends with 0}.
• {๐‘ค โˆถ ๐‘’๐‘ฃ๐‘’๐‘Ÿ๐‘ฆ ๐‘œ๐‘‘๐‘‘ ๐‘๐‘œ๐‘ ๐‘–๐‘ก๐‘–๐‘œ๐‘› ๐‘–๐‘› ๐‘ค is 1}.
• {๐‘ค โˆถ ๐‘ค has length at least 3 and its third symbol is 0}.
• {∈ ,0}
i. Construct RE for the above Languages by constructing minimized DFA.
ii. Convert and compare the NFA to DFA and write your comments.
2. Translate the Melay machine into its equivalent Moore machine. Construct equivalent DFA for
the Moore Machine by considering output 1 as accepted and 0 as rejected. Write a RE for the
constructed DFA.
3. Construct NFA for the given ฯต-NFA
i. Convert the NFA to DFA
ii. Reduce the number of states for the above constructed DFA and design Minimized
DFA.
4. Construct Mealy Machine and Moore machine that takes all binary numbers as input and
produces Y as output if last two symbols are same. Otherwise, produces N as output.
Convert the above machines from Mealy to Moore and Moore to Mealy.
5. Consider a Deterministic Finite Automaton (DFA) which takes N states numbered from 0 to
N-1, with alphabets 0 and 1. Now consider a string of 0s and 1s, let the decimal value of this
string as M. For e.g., if string be "010" then the decimal value or M is 2. The speciality in our
DFA is that when we simulate the string through this DFA, it finally takes us to the state with
the same number as of M%N, where % is the modulus operator. For e.g. if our string is "1100"
i.e. M is 12 and N is 5, then after simulating this string through DFA, it will reach to state 12%5
i.e. state no. 2. Since M%N can be any number from 0 to N-1, and the states in our DFA are
also from 0 to N-1, there must always be some state we will reach. Assume the starting state of
DFA is 0. You are given N, the no. of states in our DFA. Print a transition table for this DFA.
Write the regular expression for the above language as well as construct the minimized DFA.
6. Consider the Finite Automata given by the transition table:
a
b
*c
d
e
f
g
h
i.
ii.
iii.
iv.
0
1
b
g
a
c
h
c
g
g
f
c
c
g
f
g
e
c
Construct minimized FA for the give FA
Write the regular expression for the above transition table
Construct the DFA for the above RE
Construct the minimum state equivalent DFA.
7. Recall (part of) the Roman numeral system: I = 1, V = 5, X = 10, L = 50, C = 100. Recall also
that in a valid Roman numeral, strings such as IIIII or VV are not allowed, since there are
alternative representations using larger values, such as V and X, respectively.
Draw a DFA that accepts exactly the set of valid Roman numerals between 1 and 100 that are
strictly ordered: that is, no letter may appear after a letter that has a smaller value. Thus 9 must
be represented by VIII rather than by IX. The alphabet for your DFA should be {I, V, X, L,
C}. You should adopt the convention that edges not drawn lead to a unique "dead" or "trap"
state, which is nonaccepting, and which has edges leading back to itself on any input. Also, be
sure that your DFA doesn't accept any numeral with value 101 or more.
8. Consider the language L which accepts all strings of a’s and b’s where each string contains 5th
symbol from RHS is a.
i.
Derive the strings which belong to the above language.
ii.
Design NFA for the above language.
iii.
Design equivalent DFA for the obtained NFA.
iv.
Design minimized DFA for the obtained DFA.
v.
Derive the Regular Expression accepted by minimized DFA.
Consider from LHS, 5th Symbol as a and construct the finite automata from i-v.
9. For each of the following languages, construct an NFA that accepts the language. In all cases,
the alphabet is {0,1}.
• {๐‘ค โˆถ ๐‘ค ๐‘๐‘œ๐‘›๐‘ก๐‘Ž๐‘–๐‘›๐‘  ๐‘กโ„Ž๐‘’ ๐‘ ๐‘ข๐‘๐‘ ๐‘ก๐‘Ÿ๐‘–๐‘›๐‘” 11001}.
• {๐‘ค โˆถ ๐‘ค โ„Ž๐‘Ž๐‘  ๐‘™๐‘’๐‘›๐‘”๐‘กโ„Ž ๐‘Ž๐‘ก ๐‘™๐‘’๐‘Ž๐‘ ๐‘ก 2 ๐‘Ž๐‘›๐‘‘ ๐‘‘๐‘œ๐‘’๐‘  ๐‘›๐‘œ๐‘ก ๐‘’๐‘›๐‘‘ ๐‘ค๐‘–๐‘กโ„Ž 10}.
• {๐‘ค โˆถ ๐‘ค ๐‘๐‘’๐‘”๐‘–๐‘›๐‘  ๐‘ค๐‘–๐‘กโ„Ž 1 ๐‘œ๐‘Ÿ ๐‘’๐‘›๐‘‘๐‘  ๐‘ค๐‘–๐‘กโ„Ž 0}.
i. Construct DFA for the above designed NFA
ii. Mention the transition table for the above DFA
iii. Design the minimized DFA for the above DFA with reduced no. of states
10. For each of the following regular expressions, give two strings that are memberes and two
strings that are not members of the language described by the expression. The alphabet is ๐›ด =
{๐‘Ž, ๐‘}.
• a(ba)*b.
• (a∪ ๐‘)*a(a∪ ๐‘)*b(a∪ ๐‘)*a(a∪ ๐‘)*.
• (a ∪ ba ∪ bb)(a ∪ b)*.
i. Construct DFA for the above RE
ii. Mention the transition table for the above DFA
iii. Design the minimized DFA for the above DFA with reduced no. of states
Download