[PDF] Homework 3 Solutions is a DFA D such





Previous PDF Next PDF



Conversion Table A = 1 B = 2 C = 3 D = 4 E = 5 F = 6 G = 7 H = 8 I

The first part was easy take each letter in your name and convert it to a number. Use the system where an A=1



English Class -1 & 2 Below Level Cover page Final for Printing-31 English Class -1 & 2 Below Level Cover page Final for Printing-31

Can write 3 letters words. Assessment-8. Can use article. Assessment-9. Can * Write a to z in small letters with correct strokes: 9. Date : Teacher's ...



Vocabulary can be reinforced by using a variety of game formats Vocabulary can be reinforced by using a variety of game formats

Each of these words ends in the same four letters but has a different first letter. What are they? 1. Power. 2. Vision. 3. Opposite of loose. 4. Not dark 



The Alphabet Cube and Beyond

This time imagine an additional axis



Homework 3 Solutions

A variable name must start with a Roman letter: a b



actions-verbs-a-to-z.pdf

Actions Verbs A to Z. A. Accelerated. Accomplished. Achieved. Acquired. Adapted Page 3. Prepared. Prescribed. Presented. Presided. Prioritized. Processed.



Avoidable Words

letters to words on 3 letters. But you don't want to see it. The images of On four letters the space of Z-words avoiding ∆ is perfect and in fact a ...



Solutions to Exercises Marked with sG from the book Introduction to

The probabilities are equal since for both 2-letter and 3-letter words



answer key

3-letter words: and any



cat cat mat cap rat can bat cab Rhyming Short Vowel Words And cat cat mat cap rat can bat cab Rhyming Short Vowel Words And

01-Dec-2019 Sometimes the letter s represents the z sound in words. This is ... This will make it easier for stu- dents to read the three letter short vowel ...



Conversion Table A = 1 B = 2 C = 3 D = 4 E = 5 F = 6 G = 7 H = 8 I

C = 3 Z = 26. Classroom Activity 2. Math 113. The Dating Game. Introduction: ... said “You take the letters in her name



Letters and Sounds: Principles and Practice of High Quality Phonics

and words containing the new letter (week 3 onwards) z zz qu*. *The sounds traditionally taught for the letters x and qu (/ks/ and /kw/) are both two.



Guidelines for Alphabetical Arrangement of Letters and Sorting of

3. 3.4 Symbols Other Than Numerals Letters and Punctuation Marks . of the characters or words in a heading are not permitted.



1. How many permutations of 3 different digits are there chosen

Assuming that any arrangement of letters forms a 'word' how many 'words' of any length can be formed from the letters of the word SQUARE? (No repeating of 



GimmeNotes

How many words does this language have of length 2? of length 3? of length n? Suppose z has length k: z1 z2…z(k-1) zk = letters in z.



Critical exponents of words over 3 letters

alphabet) there exists an infinite word over 3 letters whose critical exponent is ?. v is a a). z being a prefix of u



Shift (Caesar) Ciphers If you have a message you want to transmit

we use to replace the “z” when we encrypt? After performing a shift cipher encryption with encryption key 3 the message “pizza” becomes. SLCCD. The letter 



Homework 3 Solutions

is a DFA D such that L(D) = L(M) = C. By problem 3 on Homework 2 we A variable name can only use Roman letters (i.e.



CRYPTOGRAPHY You may know what this means ···

3. To see how to decode simple substitution ciphers without a key using frequency of letters and words. 4. To understand the difference between classical 



J Q

Z Words (2-

CS 341: Foundations of Computer Science II

Prof. Marvin Nakayama

Homework 3 Solutions

1. Give NFAs with the specified number of states recognizing each ofthe following lan-

guages. In all cases, the alphabet isΣ ={0,1}. (a) The language{w?Σ?|wends with00}with three states. 123
0,1 00 (b) The language{w?Σ?|wcontains the substring0101, i.e.,w=x0101yfor somex,y?Σ?}with five states. 12345
0,1 0101
0,1 (c) The language{w?Σ?|wcontains at least two0s, or exactly two1s}with six states. 1 2 5 34
60
0,1 0 1 0 0,1 1 0 1 0 (d) The language{ε}with one state. 1 1 (e) The language0?1?0?0with three states. 123
0 1 0 0

2. (a) Show by giving an example that, ifMis an NFA that recognizes languageC,

swapping the accept and non-accept states inMdoesn"t necessarily yield a new

NFA that recognizes

C.

Answer:

The NFAMbelow recognizes the languageC={w?Σ?|wends with00}, whereΣ ={0,1}. 123
0,1 00 Swapping the accept and non-accept states ofMgives the following NFAM?: 123
0,1 00 Note thatM?accepts the string100??C={w|wdoes not end with00}, so M ?does not recognize the language C. (b) Is the class of languages recognized by NFAs closed under complement? Explain your answer.

Answer:

The class of languages recognized by NFAs is closed under complement, which we can prove as follows. Suppose thatCis a language recognized by some NFAM, i.e.,C=L(M). Since every NFA has an equivalent DFA (Theorem 1.39), there is a DFADsuch thatL(D) =L(M) =C. By problem 3 on Homework 2, we then know there is another DFA

Dthat recognizes the languageL(D). Since

2 every DFA is also an NFA, this then shows that there is an NFA, in particularD, that recognizes the language

C=L(D). Thus, the class of languages recognized

by NFAs is closed under complement.

3. Use the construction given in Theorem 1.39 to convert the following NFANinto an

equivalent DFA. 12 3 a a a,b b Answer:Let NFAN= (Q,Σ,δ,1,F), whereQ={1,2,3},Σ ={a,b},1is the start state,F={2}, and the transition functionδas in the diagram ofN.

To construct a DFAM= (Q?,Σ,δ?,q?

0,F?)that is equivalent to NFAN, first we

compute theε-closure of every subset ofQ={1,2,3}.

SetR?Qε-closureE(R)

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

Then defineQ?=P(Q), so

Q ?={ ∅,{1},{2},{3},{1,2},{1,3},{2,3},{1,2,3} }. The start state ofMis thenE({1}) ={1,2}. The set of accept states ofMis F ?={ {2},{1,2},{2,3},{1,2,3} }. We define the transitions in the DFAMas in the following diagram: 3 {1,2} {2,3} {1,2,3}a b ab a,b b a Note that we left out some of the states (e.g.,{1}) inP(Q)from our diagram of the DFAMsince they are not accessible from the start state{1,2}. Also, we had to add an arc from state∅to itself labelled with "a,b" so that this state has an arc leaving it corresponding to each symbol in the alphabetΣ, which is a requirement for any DFA. The algorithm given in the notes and textbook will always correctly construct an equivalent DFA from a given NFA, but we don"t always have to go through all the steps of the algorithm to obtain an equivalent DFA. For example, on this problem, we begin by figuring out what states the NFA can be in without reading any symbols. In this case, this isE({1}) ={1,2}since1is the starting state of the NFA, and the NFA can jump from1to2without reading any symbols by taking theε-transition. Thus, we first create a DFA state corresponding to the set{1,2}: {1,2} The state{1,2}is the start state of the DFA since this is where the NFA can be without reading any symbols. The state{1,2}is also an accepting state for the DFA since it contains2, which is accepting for the NFA. Now for DFA state{1,2}, determine where the NFA can go on anafrom each NFA state within this DFA state, and where the NFA can go on abfrom each NFA state within this DFA state. On ana, the NFA can go from state1to state3; also, the NFA can go from state2to1, and then it also can go further from1to2on theε. So from NFA states1and2on ana, the NFA can end up in states1,2, and3, so draw a transition in the DFA from state{1,2}to a new state{1,2,3}, which is an accepting state since it contains2?F: 4 {1,2}{1,2,3}a Similarly, to determine where the DFA moves onbfrom DFA state{1,2}, determine all the possibilities of where the NFA can go from NFA states1and2onb. From state1, the NFA can"t go anywhere on ab; also, the NFA can"t go anywhere from state2onb. Thus, the NFA can"t go anywhere from states2and3on ab, so we add ab-edge in the DFA from state{1,2}to a new DFA state∅, which is not accepting since it contains no accept states of the NFA: {1,2} {1,2,3}a b Now every time we add a new DFA state, we have to determine all the possibilities of where the NFA can go on anafrom each NFA state within that DFA state, and where the NFA can go on abfrom each NFA state within that DFA state. For DFA state {1,2,3}, we next determine where the NFA can go on anafrom each of the NFA states1,2and3. From NFA state1, the NFA on anacan go to NFA state3; from NFA state2, the NFA on anacan go to NFA state1, and then it can also further jump to2onε; from NFA state3, the NFA on anacan go to NFA state2. Thus, if the NFA is in states1,2and3, it can go on anato states1,2and3, so we add to the DFA ana-edge from{1,2,3}to{1,2,3}. {1,2} {1,2,3}a b a Now we determine where theb-edge from DFA state{1,2,3}goes to. To do this, we examine what happens to the NFA from states1,2and3on ab. If the NFA is in state1, then there is nowhere to go on ab; if the NFA is in state2, then there is nowhere to go on ab; if the NFA is in state3, then the NFA can go to2or3onb. Hence, if the NFA is in states1,2and3, the NFA onbcan end in states2and3. Thus, in the DFA, draw an edge from state{1,2,3}to a new state{2,3}, which is accepting since it contains2?F: 5 {1,2} {2,3} {1,2,3}a b b a Now do the same for DFA states{2,3}and∅. If any new DFA states arise, then we need to determine theaandbtransitions out of those states as well. We stop once every DFA state has ana-transition and ab-transition out of it. Accepting states in the DFA are any DFA states that contain at least one accepting NFA state. We eventually end up with the DFA below as before: {1,2} {2,3} {1,2,3}a b ab a,b b a For the DFA state∅, there are no versions of the NFA currently active, i.e., all "threads" have "crashed," so the NFA cannot proceed and the input string willnot be accepted. However, according to the definition of a DFA, each state must have edges leaving it corresponding to each symbol in the alphabetΣ. Thus, we add a loop from the DFA state∅back to itself labeled withΣ, which in our case isa,b.

4. Give regular expressions that generate each of the following languages. In all cases,

the alphabet isΣ ={a,b}. 6 (a) The language{w?Σ?| |w|is odd}.

Answer:(a?b)((a?b)(a?b))?

(b) The language{w?Σ?|whas an odd number ofa"s}.

Answer:b?a(ab?a?b)?

(c) The language{w|wcontains at least twoa"s, or exactly twob"s}.

Answer:b?ab?a(a?b)??a?ba?ba?

(d) The language{w?Σ?|wends in a double letter}. (A string contains adouble letterif it containsaaorbbas a substring.)

Answer:(a?b)?(aa?bb)

(e) The language{w?Σ?|wdoes not end in a double letter}.

Answer:ε?a?b?(a?b)?(ab?ba)

(f) The language{w?Σ?|wcontains exactly one double letter}. For example, baabahas exactly one double letter, butbaaabahas two double letters.

5. Suppose we define a restricted version of the Java programminglanguage in which

variable names must satisfy all of the following conditions: ?A variable name can only use Roman letters (i.e.,a,b, ...,z,A,B, ...,Z) or Arabic numerals (i.e.,0,1,2, ...,9); i.e., underscore and dollar sign are not allowed. ?A variable name must start with a Roman letter:a,b, ...,z,A,B, ...,Z ?The length of a variable name must be no greater than 8. ?A variable name cannot be a keyword (e.g., if). The set of keywords isfinite. LetLbe the set of all valid variable names in our restricted version of Java. (a) LetL0be the set of strings satisfying the first 3 conditions above; i.e., we do not require the last condition. Give a regular expression forL0. Answer:To simplify the regular expression, we define

1={a,b,...,z,A,B,...,Z}

2={0,1,2,...,9}.

Then a regular expression forL0is

7 times.

Note that by including theεin each of the last parts, we can generate strings that have length strictly less than 8. 7 (b) Prove thatLhas a regular expression, whereLis the set of strings satisfying all four conditions. Answer:We proved in Homework 1, problem 4(b), thatLis finite. Thus,Lis regular, so it has a regular expression. Although the problem didn"t ask for it, we can write a regular expression forLby listing all of the strings inLand putting a?in between each pair of consecutive strings. This works becauseLis finite. (c) Give a DFA for the languageL0in part (a), where the alphabetΣis the set of all printable characters on a computer keyboard (no control characters), except for parentheses to avoid confusion. Answer:DefineΣ1andΣ2as in part (a), and letΣ3= Σ-(Σ1?Σ2)be all of the other characters on a computer keyboard except for parentheses. Then a

DFA forL0is as follows:

12349
0 Σ1

Σ2?Σ3

Σ1?Σ2

Σ3

Σ1?Σ2

Σ3 Σ3

6. DefineLto be the set of strings that represent numbers in a modified version of Java.

The goal in this problem is to define a regular expression and an NFA forL. To precisely defineL, let the set ofdigitsbeΣ1={0,1,2, ...,9}, and define the set ofsignsto beΣ2={+,-}. ThenL=L1?L2?L3, where ?L1is the set of all strings that are decimal integer numbers. Specifically,L1 consists of strings that start with an optional sign, followed by oneor more digits. Examples of strings inL1are "02", "+9", and "-241". ?L2is the set of all strings that are floating-point numbers that are not in expo- nential notation. Specifically,L2consists of strings that start with an optional sign, followed by zero or more digits, followed by a decimal point, and end with zero or more digits, where there must be at least one digit in the string. Examples of strings inL2are "13.231", "-28." and ".124". All strings inL2have exactly one decimal point. ?L3is the set of all strings that are floating-point numbers in exponential notation. Specifically,L3consists of strings that start with a string fromL1orL2, followed by "E" or "e", and end with a string fromL1. Examples of strings inL3are "-80.1E-083", "+8.E5" and "1e+31". Assume that there is no limit on the number of digits in a string inL. Also, we do not allow for the suffixesL,l,F,f,D,d, at the end of numbers to denote types (long integers, floats, and doubles). DefineΣas the alphabet of all printable characters on a computer keyboard (no control characters), except for parentheses to avoid confusion. 8 (a) Give a regular expression forL1. Also, give an NFA and a DFA forL1over the alphabetΣ.

Answer:A regular expression forL1is

R

1= (+?-?ε)Σ1Σ?1

quotesdbs_dbs14.pdfusesText_20
[PDF] a to z words for kids

[PDF] a to z words list for kindergarten

[PDF] a to z words list with meaning

[PDF] a to z words that describe god

[PDF] a to z words to describe someone

[PDF] a to z words with pictures pdf

[PDF] a to z words with sentences

[PDF] a ton of refrigeration effect is defined as the

[PDF] a ton of refrigeration is defined as

[PDF] a ton of refrigeration is equal to quizlet

[PDF] a ton of refrigeration meaning

[PDF] a tout a l'heure bibio

[PDF] a tout a l'heure in english

[PDF] a tout a l'heure lyrics

[PDF] a tout a l'heure lyrics meaning