Docsity

Practice Problems 2 - Regular Expressions and Languages | CMSC 330, Exams of Programming Languages

Toggle sidebar
bg1
CMSC 330, Practice Problems 2
1. Regular expressions and languages
a. From the perspective of formal language theory, what is a language?
b. Given the language A = {โ€œaaโ€, โ€cโ€} and B = {โ€œbโ€}, what is the language AB?
c. Given the language A = {โ€œaaโ€, โ€cโ€}, what is the language A
0
?
d. Given the language A = {โ€œaaโ€, โ€cโ€}, what is the language A
2
?
e. Given the language A = {โ€œaaโ€, โ€cโ€}, what is the language A*?
f. Give a regular expression for all binary numbers including the substring โ€œ101โ€.
g. Give a regular expression for all binary numbers with an even number of 1โ€™s.
h. Give a regular expression for all binary numbers that donโ€™t include โ€œ000โ€.
2. Finite automata
a. When does a NFA accept a string?
b. How long could it take to reduce a NFA with n states and t transitions to a
DFA?
c. Give a NFA that only accepts binary numbers including the substring โ€œ101โ€.
d. Give a NFA that only accepts binary numbers that include either โ€œ00โ€ or โ€œ11โ€.
e. Give a NFA that only accepts binary numbers that include both โ€œ00โ€ and โ€œ11โ€.
f. What language (or set of strings) is accepted by the following NFA?
g. Compute the ฮต-closure of the start state for each of the NFA above.
h. Give a DFA that only accepts binary number with an odd number of 1โ€™s.
i. Give a DFA that only accepts binary numbers that include โ€œ000โ€.
j. Give a DFA that only accepts binary numbers that donโ€™t include โ€œ000โ€.
k. What language (or set of strings) is accepted by the following DFA?
pf2

Partial preview of the text

Download Practice Problems 2 - Regular Expressions and Languages | CMSC 330 and more Exams Programming Languages in PDF only on Docsity!

CMSC 330, Practice Problems 2

  1. Regular expressions and languages a. From the perspective of formal language theory, what is a language? b. Given the language A = {โ€œaaโ€, โ€cโ€} and B = {โ€œbโ€}, what is the language AB? c. Given the language A = {โ€œaaโ€, โ€cโ€}, what is the language A^0? d. Given the language A = {โ€œaaโ€, โ€cโ€}, what is the language A^2? e. Given the language A = {โ€œaaโ€, โ€cโ€}, what is the language A*? f. Give a regular expression for all binary numbers including the substring โ€œ101โ€. g. Give a regular expression for all binary numbers with an even number of 1โ€™s. h. Give a regular expression for all binary numbers that donโ€™t include โ€œ000โ€.
  2. Finite automata a. When does a NFA accept a string? b. How long could it take to reduce a NFA with n states and t transitions to a DFA? c. Give a NFA that only accepts binary numbers including the substring โ€œ101โ€. d. Give a NFA that only accepts binary numbers that include either โ€œ00โ€ or โ€œ11โ€. e. Give a NFA that only accepts binary numbers that include both โ€œ00โ€ and โ€œ11โ€. f. What language (or set of strings) is accepted by the following NFA?

g. Compute the ฮต-closure of the start state for each of the NFA above. h. Give a DFA that only accepts binary number with an odd number of 1โ€™s. i. Give a DFA that only accepts binary numbers that include โ€œ000โ€. j. Give a DFA that only accepts binary numbers that donโ€™t include โ€œ000โ€. k. What language (or set of strings) is accepted by the following DFA?

l. For each regular expression: 1, (0|01) i. Reduce the RE to an NFA using the algorithm described in class. ii. Reduce the resulting NFA to an DFA using the subset algorithm. iii. Show whether the DFA accepts / rejects the strings โ€œ1โ€, โ€œ11โ€, โ€œ101โ€ iv. Minimize the resulting DFA using Hopcroft reduction v. Are any 2 of the minimized DFA identical?