You are on page 1of 11

University of Houston-Downtown

Department of Computer and Mathematical Sciences


CS 3306Spring 2013 Exam II Name: _________________________________ ID: ___________________________
This exam is a closed book closed notes exam. Answer all questions on a scantron. [50 questions, 2 points each]

1. If L and M are regular expressions, which of the following is not a regular expression? A. L + M B. L M C. L* D. (LM)* 2. What is the right language that describes regular expression ab* + c? A. {a, c, b, bb, bbb, , bn, } B. {, a, c, b, bb, bbb, , bn, } C. {, a, c, ab, abb, abbb, , abn, } D. {a, c, ab, abb, abbb, , abn, }
P P P P P P

3. What is the right regular expression that describes the following language? {, ab, abbb, abbbbb, , ab2n+1, }
P P

A. B. C. D.

ab* +ab* a(bb)*b + a(bb)*b

4. What is the right regular expression that describes the following language? {, a, b, c, aa, bb, cc, , an, bn, cn, }
P P P P P P

A. B. C. D.

a+b+c +a+b+c a* + b* + c* a*b*c*

5. What is the right regular expression for strings whose length is multiple of 3 over the alphabet {a, b}? A. (a + b)*
1

B. (aaa + bbb)* C. (aaa)* + (bbb)* D. ((a + b + c)( a + b + c)(a + b + c))* 6. What is the correct simplified form of the following regular expression? aa(b* + a) + a(ab* + aa) A. B. C. D. b* + a a(b* + a) aa(b* + a) aa(b* + a) + aa(b* + a)

7. Find the correct equality: A. * = B. * = C. * = D. * = 8. Find the incorrect equality: A. R* = (R*)* B. R* = R + R* C. R* = RR* D. R* = + R* 9. Which of the following is untrue about DFA? A. Each state emits one labeled edge for each letter of alphabet A. B. One state is designated as the start state. C. There must be at least a final state D. There may not be any final states 10. With the following DFA, which state is a final state?

A. B. C. D.

0 1 2 It doesnt have final state

11. Referring to the DFA in Question 10, what is the correct transition function for state 1? A. T(1, a) = 1; T(1, b) = 1 B. T(1, a) = 1; T(1, b) = 2

C. T(1, a) = 2; T(1, b) = 1 D. T(1, a) = 2; T(1, b) = 2 12. Which input string is accepted by the DFA in Question 10? A. B. b C. ba D. baa 13. Referring to the DFA in Question 10, what does T(0, bba) equal to? A. 0 B. 1 C. 2 D. Undefined 14. The following is a DFA designed for regular expression ba*. Find proper labels in numbered positions for the transitions.
3

1 4 5 2

A. B. C. D.

1 a; 2 b; 3 a; 4- b; 5 a, b 1 b; 2 a; 3 a; 4- b; 5 a, b 1 a; 2 a; 3 b; 4- b; 5 a, b 1 b; 2 b; 3 a; 4- a; 5 a, b

15. What is untrue about NFA? A. -edges are allowed B. There is no requirement to emit edges from a state C. Multiple edges with the same letter can be emitted from a state D. It is a special case of DFA 16. Given the following NFA, what is the correct transition function for state 0?

A. B. C. D.

T(0, a) = 0; T(0, b) = 1 T(0, a) = {0}; T(0, b) = {1}; T(0, ) = T(0, a) = {0, 1}; T(0, b) = ; T(0, ) = T(0, a) = ; T(0, b) = {0, 1}; T(0, ) =

17. Which of the following input strings is accepted by the NFA in Question 16?

A. B. C. D.

a b ab

18. The following figure shows the first 2 steps of transforming an NFA to regular expression. What is the correct label for the transition with a question mark?

A. B. C. D.

ba*a ab*b bb*a aa*b

19. Transform the following single state NFA into a regular expression, where state 0 is the start state and final state. What is the resultant regular expression? T(0, a) = {0}, T(0, b) = {0} A. B. C. D. a* + b* (a + b)* a*b* (ab)*

20. The following figure shows the first 3 steps of transforming regular expression a(a* + b)* to an NFA. What is the label of the transition with a question mark in Step 3?

Start

a(a* + b)*

Start

(a* + b)* ?

Start

A. B. C. D.

a* + b (a* + b)* a a, b

21. Given the following NFA, what is the -closure of state 0? a {2} b {1, 2} {0} {2} {1} {1}

Start 0 1 Final 2 A. B. C. D. {0} {1} {0, 1} {0, 1, 2}

22. Referring to the NFA in Question 21, what is ({0, 1})? A. {0} B. {1} C. {0, 1} D. {0, 1, 2} 23. The following is the DFA table constructed from the NFA in Question 21. What is the missing entry? a {2} {2} b ? {0, 1, 2} {2}

S {0, 1} F {0, 1, 2} F {2} A. B. C. D. {0, 1} {2} {0, 1, 2}

24. Given the following DFA, what is set E 0 for transforming the DFA to minimum state DFA? a 1 3 3 3 b 2 1 2 3

Start 0 Final 1 Final 2 3 A. B. C. D.

{{0, 1}, {2, 3}} {{0, 1}, {0, 2}, {1, 2}} {{0, 3}, {1, 2}} {{0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}}

25. Given the following DFA, set E 0 is constructed to transform the DFA to minimum state DFA. What is E 1 ? a 1 3 3 3 b 2 1 2 3

Start 0 1 2 Final 3

E 0 = {{0, 1}, {0, 2}, {1, 2}} A. B. C. D. E1 E1 E1 E1 = {{1, 2}} = {{0, 1}, {1, 2}} = {{0, 2}, {1, 2}} = {{0, 1}, {0, 2}, {1, 2}}

26. Let S be the set of states that can be reached from the start state of a DFA over A. The definition of the equivalence relation of states is: For states s, t S, s ~ t if for all strings w A*, A. T(s, w) and T(t, w) are identical. B. T(s, w) and T(t, w) are both final. C. T(s, w) and T(t, w) are both nonfinal. D. either T(s, w) and T(t, w) are both final or both nonfinal. 27. Given the following DFA, are state 0 and 1 equivalent?

A. True B. False 28. The following procedure shows the computation of set E i s for a DFA. What states are equivalent based on the computation?

A. B. C. D.

1 ~ 5 only 2 ~ 4 only 1 ~ 5 and 2 ~ 4 1~2~4~5

29. Given the following DFA, find out what states are equivalent.

A. B. C. D.

1~2 2~3 1~3 1~2~3

30. Given the following DFA and the fact that 1 ~ 5 and 2 ~ 4, what is the transition function for state [1] in the corresponding minimum state DFA?

A. B. C. D.

T([1], a) = 5, T([1], b) = 2, T([1], c) = 1 T([1], a) = 5, T([1], b) = 4, T([1], c) = 5 T([1], a) = [1], T([1], b) = [2], T([1], c) = [1] T([1], a) = [1], T([1], b) = [2], T([1], c) = [3]

31. Which of the following grammars is a regular grammar? A. S -> aS | b B. S -> aSa | b C. S -> SaS | b D. S -> aS | Sa | b 32. Which of the following grammars is not a regular grammar? A. S -> aS | b B. S -> Sa | b C. S -> aaS | b D. S -> aS | Sa | b 33. Which of the following grammars is a right regular grammar? A. S -> abS | ab B. S -> aSS | b C. S -> SaS | b D. S -> aSa | b 34. Which of the following grammars is a left regular grammar? A. S -> abS | ab B. S -> aSb | ba

C. S -> Sab | ab D. S -> SSa | b 35. Which of the following is a left regular grammar for the language represented by regular expression (a +b*)a? A. S -> Ta; T -> a | bT B. S -> Ta; T -> a | U; U -> bU | C. S -> Ta; T -> a | U; U -> Ub | D. S -> aT; T -> a | U; U -> Ub | 36. Which of the following is a right regular grammar for the language represented by regular expression (a +b*)a? A. S -> Ta; T -> a | U; U -> Ub | B. S -> aa | aT; T -> bT | C. S -> aa | T; T -> bT | D. S -> aa | T; T -> bT | a 37. Which of the following languages is described by regular grammar S -> abS | c? A. {c, ab, abab, ababab, , (ab)n, } B. {c, abc, ababc, abababc, , (ab)nc, } C. {c, cab, cabab, cababab, , c(ab)n, } D. {, abc, ababc, abababc, , (ab)nc, } 38. Which NFA is the resultant NFA transformed from the following grammar? S aS | T T bbT | A. S a

b T b

B. S a

T b b I

C. S a the

D. T b b I S a 39. What is grammar following NFA?

T b b I the regular transformed from

A. S -> T | aI I -> bS T -> cT | dF B. S -> T | aI | I -> bS T -> cT | dF F -> C. S -> T | abS | T -> cT | d D. B and C above 40. Which of the following languages is not a regular language? A. {, a, b, aa, bb, aaa, bbb, , an, bn, } B. {, ab, aabb, aaabbb, , anbn, } C. {, ab, abab, ababab, , (ab)n, } D. B and C above 41. What is a correct context free grammar for language { anbn+1 | n 0} A. S -> aSb | B. S -> aSb | b C. S -> aSb | bb D. S -> aSb | a 42. What is a correct context free grammar for the following language defined over the alphabet {a, b, c}: L = {anbmck | n, m, k 0 and either n = m or m = k}. A. S -> AB A -> aAb | B -> cB | B. S -> AB A -> aA | B -> bBc | C. S -> AB A -> aAb | B -> bBc | D. S -> AB | CD

A -> aAb | B -> cB | C -> aC | D -> bDc | 43. What is a correct context-free grammar for language {anbn | n 0}*? A. S -> aSb | B. S -> AS | A A -> aAb | C. S -> SA | A -> aAb | ab D. Both B and C 44. What is the language recognized by the following grammar? S -> aSb | A. B. C. D. {anbn | n 0} {(ab)n | n 0} {anbn | n 1} {(ab)n | n 1}

45. Which production should be in the grammar for a language L = M N, where A is the start symbol for M and B the start symbol for N, and S is the start symbol for L? A. S -> A | B B. S -> AB C. S -> AS | D. S -> BS | 46. Which production should be in the grammar for a language L = MN, where A is the start symbol for M and B the start symbol for N, and S is the start symbol for L? A. S -> A | B B. S -> AB C. S -> AS | D. S -> BS | 47. Which production should be in the grammar for a language L = M*, where A is the start symbol for M, and S is the start symbol for L? A. S -> AS | B. S -> SA | C. S -> AS | A D. Either A or B

10

48. Which production should be in the grammar for a language L = M+, where + means concatenation of n strings in M and n 1, A is the start symbol for M, and S is the start symbol for L? A. S -> AS | B. S -> SA | C. S -> AS | A D. Either A or B 49. What is a correct context-free grammar for a language defined as {anbn | n 0} {anb2n | n 0}? A. S -> A | B A -> aAb | B -> aAbb | B. S -> AB A -> aAb | B -> aAbb | C. S -> SA | B A -> aAb | B -> aAbb | D. S -> SB | A A -> aAb | B -> aAbb | 50. What is a correct context-free grammar for a language defined as {anbn | n 0}{anb2n | n 0}? A. S -> A | B A -> aAb | B -> aAbb | B. S -> AB A -> aAb | B -> aAbb | C. S -> SA | B A -> aAb | B -> aAbb | D. S -> SB | A A -> aAb | B -> aAbb |

11

You might also like