CS 130

advertisement
CS 130
Sample Test
July 30, 2005
1. Define a context free grammar on the alphabet {0, 1} that generates
palindromic strings.
2. Define a right-linear grammar on the alphabet {0, 1} that generates strings of
0s or strings of 1s, or strings of 0s followed by 1s.
3. Construct a DFA that reads strings of 0s and 1s, and accepts a string if the
number of 1s is divisible by 3.
4. Construct a DFA that accepts strings of 0s and 1s that contain 101 as a
substring.
5. Construct a DFA that accepts strings of 0s and 1s that do not contain 010 as a
substring.
6. Enumerate all possible reasons why a finite automaton can be
nondeterministic.
7. Construct a NFA that accepts strings of 0s and 1s that contain either 111 or
000 as a substring.
8. A real constant consists of an optional + or – sign, followed by one or more
digits 0-9, which may contain a decimal point within the digits, or after all the
digits, but not before the digits. Construct an NFA that accepts real constants.
9. Convert the NFA in Problem 7 to a DFA.
10. Convert the NFA in Problem 8 to a DFA.
11. Prove that the language L = { (01)k | k  1 } is regular by creating a regular
grammar G, such that the language generated by G is L.
Download