Finite automata and regular expressions are useful in defining the

advertisement
CS 454 Theory of Computation




Fall 2002
Mid-term test # 1 will be on Thurday, October 17.
All topics covered in the course until (and including) October 15 will be part of
the test.
The test will be closed-book/notes.
Topics covered in the lab will also be part of the test.
Mid-Semester Test # 1 practice problems
.
1) Design a DFA that accepts the set of strings over {0,1} such that every block of
three consecutive symbols contains at least one 1. (Strings of length 0, 1 and 2 are
to be accepted.)
2) Write a regular expression that generates all the strings (over {a, b}) having an
even number of 0’s or an odd number of 1’s.
3) Let L be the set of strings over {0, 1}in which the number of 0’s is not twice the
number of 1’s. Show that L is not regular.
4) Convert the NFA shown in the figure below into an equivalent DFA:
5) Write a context-free grammar that generates the language
A = { ai bj ck | i, j, k >= 0, and either i = j or j = k }
6) For each statement below, state if it is true or false. Justify your answer.
(a) If L1  L2 is regular, is it true that L1 and L2 are regular?
(b) If R is a symmetric and transitive relation, is it also a reflexive relation?
(c) If L is regular, is it true that every subset of L is also regular?
1
7)
Write a one-line shell command with a call to EGREP that will help solve the
following crossword puzzle. (Recall that /usr/dict/words contains the words from
a standard dictionary.)
s
u
t
e
7) Write a one-line command calling EGREP to determine which of the two
spellings receive or recieve is correct.
8) Design an algorithm that takes as input a regular expression R and a string x, and
answers “yes” if x can be generated by R, “no” else.
9) This problem deals with curves of the kind we considered in Lab # 2 an example
of which is:
To simplify matters, the curve is supposed to start at the leftmost boundary and
end in rightmost boundary. Now let us encode such a curve using U (up) D
(down) and R (right). Thus the above curve can be encoded as URDRRURDRRU.
Design a DFA that accepts the set of such encodings.
2
Download