CSE355_SP24_mid1sol

.pdf

School

Arizona State University *

*We aren’t endorsed by this school

Course

355

Subject

Computer Science

Date

Apr 3, 2024

Type

pdf

Pages

7

Uploaded by DrTree7011

CSE 355 Page 2 M idterm 1 - S ample S olutions Question 1-5: Determine whether the given statement is True or False. If it is true, give a brief reasoning as to why, otherwise give a counter-example . ALL of the points are for the reasoning; each is worth 2 points 1. (T / F) If R is a regular expression, ( RR [ R ) R = R + TRUE : RR is R + , then RR [ R = R + because R R + . Then, it follows that ( R + ) is R . Finally, R R evaluates to R + . Common mistake is just saying ( RR [ R ) evaluates to R without explaining. 2. (T / F) A subset of a regular language is regular. FALSE : Every nonregular language is a subset of the regular language . 3. (T / F) Let L 1 = L 2 L 3 . If L 2 is regular and L 3 is not regular, L 1 is never regular. FALSE : Let L 2 = L (1 ) and it is surely regular. Let L 3 = { 1 n | n is a prime number } , which is not regular (proved in the problem set for PL). The concatenation of L 2 and L 3 is L 1 = L (111 ). It is surely regular because it is expressed in a regular expression. 4. (T / F) L 1 is an infinite regular language. Every DFA M where L ( M ) = L 1 , contains at least one cycle in its state diagram. TRUE : If L 1 is infinite regular language and M is a DFA that recognizes L 1 , there always is a string w 2 L 1 , where | w | > = | Q | , ( Q is the finite set of states in M ), otherwise L 1 is finite. In the accepted computation of w on M , there must be exactly | w | many transitions ( | w | + 1 states are visited) or at least as many transitions as | Q | . By pigeon hole principle, there must be at least one state that is visited multiple times, there must be a cycle in M . Common mistake is just mentioning infinite language must go through loop. Pigeon hole principle must be used to compare the length of string and the numbber of states to receive credit. 5. (T / F) The intersection of a nonregular language and a regular language cannot be regular. FALSE : The intersection of every nonregular language and the regular language ; is ; . 2 Copyright c 2024 Heewook Lee
CSE 355 Page 3 M idterm 1 - S ample S olutions Q5-10 : Determine whether the given statement is True or False. Write ‘T’ if true, ‘F’ otherwise. 6. If you used the method shown in lecture to convert (01 [ 10) into an equivalent NFA, how many total states and accept states would the machine have? [ C ] (a) 8 total states, 5 accept states (b) 6 total states, 3 accept states (c) 10 total states, 3 accept states (d) 9 total states, 5 accept states (e) None of the above 7. Let L = { www | w 2 { 0 , 1 } } . Which of the following is true? [ C ] (a) L is nonregular because 0 p 10 p cannot be pumped. (b) L is regular because the regular expression describes the language. (c) L is nonregular because 0 p 10 p 10 p 1 cannot be pumped. (d) L is regular because a finite automaton can be built to recognize it. (e) Both (a) and (c) 8. If L 1 = { a n | n 0 } and L 2 = { b n | n 0 } , consider I. L 1 · L 2 is regular language. II. L 1 · L 2 = { a n b n | n 0 } Which one of the following is correct? [ A ] (a) Only I (b) Only II (c) Both I and II (d) Neither I nor II 9. To show that a language is regular, one could give a DFA for it. One could also [ D ] (a) give a regular expression. (b) use the pumping lemma for regular languages. (c) use closure properties. (d) (a) or (c) (e) (a), (b), or (c) 10. L = { ( ab ) n : n 0 } [ E ] (a) not regular because you cannot remember n . (b) not regular because ( ab ) p cannot be pumped. (c) not regular because ( ab ) p cannot be pumped. (d) regular because it is a b . (e) regular because it is ( ab ) . 3 Copyright c 2024 Heewook Lee
CSE 355 Page 4 M idterm 1 - S ample S olutions Question L-1: ( 25 points total ) Assume = { 0 , 1 } . Let = 0 , 1 and consider the following DFA M 3 given as its state diagram and its language L . q 0 q 1 q 2 0 0 1 1 0 1 (a) Describe the language L of the given DFA in plain English ( 3 points ). All strings that end with 10. “Ending with 10” needed for any credit. Every error results in -1. (b) Describe L in plain English and directly provide a regular expression that expresses L ( L is a comple- ment language of L ). ( 3 points ). All strings that does not end with 10. Regex: " [ 0 [ (0 [ 1) (00 [ 1) 1pt for description 1pt for handling “ending with 00” and “ending with 1” 1pt for handling “ " ” and “0” (c) Describe the reversal language L R in plain English and directly draw a 4-state DFA M 0 3 that recognizes L R ( 4 points ). q 0 0 ; q 0 1 q 0 2 1 0 1 0 0,1 0,1 1pt for having a 4-state DFA 2pt for handling “the transition from start to accept with 0-1 transition” -1pt for every error This question continues on next page. 4 Copyright c 2024 Heewook Lee
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help