• When viewed as a binary number, x is not divisible by 4. • NFA’s are usually easier to “program” in. • After making the transition and successor table we get the required DFA. Deterministic Finite Automata (DFA ) • DFAs are easiest to present pictorially: Q 0 Q 1 Q 2 1. C Programming Code to Get Input from User Following C program ask to the user to enter a number to get the number entered by the user, then display the entered number on the screen The function scanf() in C is used to scan the input data like integer, character, float, etc. (In general, there is a connection between small-est number of states of a DFA and the largest set. We put an edge from state s to state q if there is an input signal σ such that T(s,σ) = q. We call a non-binary synchronizing automaton A = hQ,Σ,δi proper if for every letter a ∈ Σ, the DFA hQ,Σa,δai, where Σa:= Σ \ {a} and δa. DFA for odd a's and even a's?? When to accept empty string??. Eight bits make up a byte. For binary number with n digits: d n-1 d 3 d 2 d 1 d 0. Let Σ = {0,1}, and L be the language consisting of all strings over {0,1} containing a 1 in the kth position from the end (in particular, all strings of length less than k are not in L). Finite automata needs minimum _____ number of stacks. Conclude that the class of regular languages is closed under complement. DFA Solved Examples. The transitions of the DFA tell us δ-hat(A,w) = A. Nfa to dfa in c Nfa to dfa in c. Problem 3 — 8 marks of 60 (filename: int. 5e) The language 0*1*0*0 (3 states) Converting NFAs to DFAs. all entries in (I+A)^d are non zero. The following ﬁgure shows an NFA for the language L 2. Construct a DFA that accepts the same language using the technique discussed in class. Therefore, what follows is the DFA for the simpler language of fw2f0;1g : whas an even lengthg. Here's an example of a DFA corresponding to the NFA for the input word 'food' with one allowable error: Note that we depicted a DFA for one error, as the DFA corresponding to our NFA above is a bit too complex to fit comfortably in a blog post! The DFA above will accept exactly the words that have an edit distance to the word 'food' of 1 or less. For a DFA accepting binary numbers whose decimal equivalent is divisible by 4, what are all the possible remainders? a) 0 b) 0,2 c) 0,2,4 d) 0,1,2,3 View Answer Answer: d Explanation: All the decimal numbers on division would lead to only 4 remainders i. binary numbers (for example: 10101011), which may seem cryptic and meaningless. ----- r901599 | jm | 2010-01-21 08:50:25 +0000 (Thu, 21 Jan 2010) | 1 line promotions validated ----- r901468 | jhardin | 2010-01-21 00:38:42 +0000 (Thu, 21 Jan 2010) | 1 line Do not publish the ADVANCE_FEE re-evolve test rules! ----- r901446 | mmartinec | 2010-01-20 23:54:29 +0000 (Wed, 20 Jan 2010) | 3 lines Bug 6295 RCVD_ILLEGAL_IP should not be eval rule - changing the rule itself. Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. E = 0 ∗ 10 ∗ ( 0 ∗ 10 ∗ 10 ∗ ) ∗ Now, let’s discuss that what strings should be accepted or rejected by our Regular Expression. Also the states and transitions of the DFA table exactly match the state machine above. The DFA method may also help identify different states of the same system exhibiting different scaling behavior—e. Example: Even 0's and 1's Suppose L1 is the binary strings with an even number of 0's, and L2 the binary strings with an even number of 1's. DFA ADVISORY. An Interactive Approach to Formal Languages and Automata with JFLAP Susan H. (d) {w ∈ {0,1}∗ | w contains an even number of the symbol 0}. 2, strong: δ*(0, x) = val(x) mod 3 •That is: the DFA ends in state iwhen the binary value of the input string, divided by 3, has remainder i •So L(M) = the set of strings that are binary representations of numbers divisible by 3 •Those examples again: -It rejects 1, 10, 100, 101, 111, and 1000…. Press button, get binaries. Design a DFA for the language over = fa;b;cg that contains all words in which there are an odd number of a’s. Conclude that the class of regular languages is closed under complement. Do all your work on the attached sheets. 2004-10-22 (Fix) For word lengths 7 or greater, searches against nucleotide sequences containing ambiguity codes could fail due to a segmentation fault. Problem: Design a DFA that accepts all strings X representing a number in a numeral system with base b (e. In 2004, the paper [20] claimed a binary worst-case example with a single accepting state. Moreover, even inﬁnite series of synchronizing n-automata whose reset thresholds is asymptotically equal to (n−1)2 turns out to be extremely rare, especially those consisting of non-binary automata. Diagonal traversal gets bigger by 1 unit for each down or right movements. In the Settings > Advanced Settings window, set the "Windows Taskbar Split Monitor ID" option to whichever split number you want it to be on, then restart DisplayFusion. Even full “steer-by-wire” functionality has been seen in a range of concept cars including GM’s widely publicized Hy-wire fuel cell vehicle [12]. Binary numbers that are greater than 101001. Obtain a DFA to accept strings of a's and b's having a sub string. Example #1. (C) Set of all palindromes made up of a’s and b’s. 5 Example #1 n Build a DFA for the following language: n L = {w | w is a binary string that contains 01 as a substring}same as n L = {w | w is of the form x01y where x,y are binary strings}same as n L = {x01y| x,y are binary strings} n Examples: 01, 010, 011, 0011, etc. Practice Problems based on Construction of DFA. DFA Construction Problems. Dividing by 2, we get 1. By constructing deterministic finite automata(DFA) of the de Bruijn graph presentation of CA, we conclude the reversibility problem of all 1D linear rules over Z 2 under null boundary conditions. a)Binary number is EVEN: Ø When binary number ends with 0 ,it is always even/When the number is divisible by 2 i. *f/ (c) Corresponding ODFA (d) ODFA with super-state transitions Fig. Write a program to Reverse the binary representation of a number. Consider the problem of computing the parity of a binary sequence. The parity is the number of occurrences of 1's in the binary sequence modulo 2. Even though methods can be derived from them, they lack performance results and are only of theoretical interest. it ﬁrst must generate a DFA from the given RegEx set. 2004-10-22 (Fix) For word lengths 7 or greater, searches against nucleotide sequences containing ambiguity codes could fail due to a segmentation fault. Internally these functions are subdivided into different modules such as measures and datasets, but you should not need to import these modules directly unless you want access to some internal helper functions. Generalizing this might be difficult and even lead to false conclusions because the form and fit is not the same for all functions. For an even number of occurrences of 0 in a binary string, we use the regular expression (1∗01∗0)∗1∗. DFA ADVISORY. L(D), the language defined by a DFA D, is the set of strings accepted by D. The paper gives complexity consequences that would result from a much-improved algorithm handling not just 2 DFAs in the intersection, but larger numbers as well. a)Binary number is EVEN: Ø When binary number ends with 0 ,it is always even/When the number is divisible by 2 i. 6, output from Disassembler & Depermutator component 213 and a pattern source including DFA from virus automaton file 206 may be input to Normalizer & DFA Simulator component 217 to complete the scanning of the binary file for virus engine and tag the binary file 604 either as a containing or not containing a virus. Rather, they are designed to be tutorial in nature, and sometimes contain a little more explanation than an ideal solution. Introduction. It may also perform secondary task at user interface. The set {ε,0,1,01} is pairwise distinguishable. Learn more about the use of binary, or explore hundreds of other calculators addressing math, finance, health, and fitness, and more. Binary is the numeral system used to express data stored in computers. S is the start state. ----- r901599 | jm | 2010-01-21 08:50:25 +0000 (Thu, 21 Jan 2010) | 1 line promotions validated ----- r901468 | jhardin | 2010-01-21 00:38:42 +0000 (Thu, 21 Jan 2010) | 1 line Do not publish the ADVANCE_FEE re-evolve test rules! ----- r901446 | mmartinec | 2010-01-20 23:54:29 +0000 (Wed, 20 Jan 2010) | 3 lines Bug 6295 RCVD_ILLEGAL_IP should not be eval rule - changing the rule itself. I was wondering, how does the concept of Prime Numbers work, in the Binary system. Give the state diagram of a DFA that recognizes the language fw j w contains an equal number of occurrences of the substrings 01 and 01g. 2 Constructing a DFA Let Σ = {0,1} and consider the language L consisting of strings x ∈ Σ∗ which satisfy the following three properties: • x has no leading 0's. For N=8 the first value tested will be the fourth value, in your case 21. (D) Strings of a’s whose length is a perfect square. ˆδ(A,w)=ˆδ(A,v1) = δ(δˆ(A,v1),1) = δ(A,1) if v contains an even number of 1’s. Case 2: a = 1. If w has an even number of 1's, then z has an odd. Define a DFA that accepts all even length binary strings that don't contain the substring "111"? Ask Question ^*$, and you've read odd number of letters ($\epsilonhas even number of letters, so it's not. WML is a good example because binary streaming is good for WML. Example 1: DFA for Binary Strings with an Even Number of 0's. Example #1. The Ascii table is split into two sections, the lower ascii table and the upper ascii table. , the number of. ) can be used for everything you can think of?. This blog is to help the people who are preparing for UGC NET on the subject Computer Science and Application. DFA Main Office. A connected graph with diameter d has at least d+1 distinct eigenvalues. DFA Solutions New Beginnings Summer 2018 1 = fsjs is a binary representation of a multiple of 5g, 5 = fsjs is an even number represented in base 3g,. there are an even number of 1's in the string. That definition leads to quick results in the Decimal system. The above DFA is the required one. It provides a number of type clasess, but not an implementation. ∑ = { 0, 1 } Q = { S, even, odd }. Now you have this bizarre constraint that the number should start with a 1. Theory on adapting the alignment principle to DFA shows that under the strong assumptions of constant DFA. Let's convert the number 46 to binary. A binary number is made up of elements called bits where each bit can be in one of the two possible states. Also give a DFA to accept the set of strings of a’s and b’s where the number of b’s is even. L0 = {binary numbers divisible by 2}\爀 䰀㄀ 㴀 笀戀椀渀愀爀礀 渀甀洀戀攀爀猀 搀椀瘀椀猀椀戀氀攀 戀礀 ㌀紀屲 L2 = {x | x ∈ {0,1}*, x\ഠdoes not contain 000 as a substring}. One state is the start state. The state S 0 is both the start state and an accept state. Formal Definition of a DFA. The pumping lemma is a theorem about a special property of regular languages. Because the term digit refers to a multiple of ten, a binary digit is called a bit. This tutorial is useful for the students of B. Convert the following NFA to its equivalent DFA using subset construction:. remainder will be 0 and the state will be represented by q 0 Ø Since the number is even, q 0 will be final state. 3 Draw NFAs for the following languages, taking full advantage of nondeterminism: (2 pts) a. Once the exam begins, write your name on each sheet. For an even-number of values N within a range being searched the mid-point is at value N/2, but the two 'halves' are of slightly different sizes. Consider each row to be a binary number and let B {w the bottom row of w is the sum of the top two rows} For example, but is easier. Applying fault attacks against white-box implementations is not new. Name your electronic file username_cs357_hwX. DFA Construction Problems. bit string interpreted as binary number is divisible by 3 bit string interpreted as binary number is divisible by 123 Boston accent. Give a simple verbal description of thc language accepted by the dfa in Figure 11. 0∗ (0∗10∗10∗10 ∗) Example 4. Use this to nd another dfa, equivalent to the given one, but with fewer states. 1 into that option. To make sense of complicated data, your computer has to encode it in binary. We also talk about them being true and false. CPS 220 – Theory of Computation Non-regular Languages Warm up Problem Problem #1. Im i right ? Thanks for contributing an answer to Mathematics Stack Exchange! Design DFA to check even number of 1s using 2 states. (3 pts) 7 Let L be the language of strings over alphabet fa;b;cg in which the number of a's, the number of b's, and the number of c's are either all even, or precisely one of them is even. So, the final states of the required DFA will contain either q1 or q2. Solution: The set of all binary strings that contain exactly three 1’s is a regular language, so there is a DFA B that recognizes this language. (The 1 + 1 because we divided the number 20 twice). In binary system, for any number such as 1011001, can we say directly "it is end with 1, so it is an odd number"?, or firstly Stack Exchange Network Stack Exchange network consists of 177 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. This dfa accepts binary strings of all 0's and also accepts strings which contain only one 1 at the end. An optional binary toggle parameter controls term frequency counts. A3: Let M be the language described as follows. (a) L 1 = fw:wdoes not contain the substring 110g (b) L 2 =fw:wcontains an even number of 0’s or exactly two 1’sg (c) L 3 is the language that consists of all strings such that between every two 0s, there is an even number of 1s. 1 into that option. Every string in L starts with a 2, ends with a 1, and contains an even number of 0's. A language defined by a DFA is said to be regular. Give a DFA for L with at most four states. Label the top of the first page with your name, CS357, and the assignment number. How to Convert Numbers to Binary: IntroductionThis instructable will show you how to convert numbers from decimal, or radix 10, to binary, or radix 2. The following example is of a DFA , with a binary alphabet, which requires that the input contains an even number of 0s. 2, strong: δ*(0, x) = val(x) mod 3 •That is: the DFA ends in state iwhen the binary value of the input string, divided by 3, has remainder i •So L(M) = the set of strings that are binary representations of numbers divisible by 3 •Those examples again: -It rejects 1, 10, 100, 101, 111, and 1000…. Applying fault attacks against white-box implementations is not new. DFA Construction Problems. Challenges must have an objective scoring criterion, and it is highly recommended to first post proposed challenges in the Sandbox. And in general this could be applied. Final states = {(q0q2), (q1q2), (q1q3)} This is our required DFA which accept the languages containing odd no. Binary relation. What is the no. 00 but keep it above. Solution: The language L3 accepts precisely those binary strings which when interpreted as numbers are exactly divisible by 3. Numbers in Computers. 5c) All strings that contains an even number of 0s or exactly two 1s. 01010 (b)All binary strings with a double symbol. b) D is even, put a 0 in the 2^6 column. In what follows we are ignoring the unreachable states. Recall that with 4 bit numbers we can represent numbers from 0 to 15. Subtract 1 from D to get D=0. The empty string is in M. a DFA for this language. Temporary Result: 10100011 New D=0 D=0, so we are done, and the decimal number 163 is equivalent to the binary number 10100011. The start state is the only. Languages (Finite State Machines) Carol Zander The DFA for signed binary numbers is larger, but still straightforward. Practice Problems based on Construction of DFA. Our automata will be M = (Q, Σ, δ, q₀, F) where Q = {S₁, S₂}, Σ = {0, 1}, q₀ = S₁, F = {S₁}, and δ is defined as follows:. tomita3 Strings with no odd number of consecutive b’s after an odd number of consecutive a’s. If it ever gets more than $1. When developing our cryptographic protocol for 328 privacy-preserving layered DFA evaluation, both the round complexity and the communication 329 complexity scales with the number of layers. A computer number system that consists of 2 numerals, 0 and 1. Design a DFA to accept string of 0’s & 1’s when interpreted as binary numbers would be multiple of 3. Give a DFA that only accepts binary numbers that don't include "000". O STOICHIOMETRY Elemental analysis of binary compounds Measurements show that unknown compound I has the following composition: element mass o zinc />. How to construct DFA- This article discusses construction of DFA with examples. Write a regular expression for each of the following sets of binary strings. 2669… • 2≠1 • 6≠5 • 6≠5 • 9≠0 • Note that no natural maps to this number. (Only for DFA) Corresponding to each state, transition rule must be specified for each letter of the alphabet. Multiplying unsigned numbers in binary is quite easy. See Figure 1. Do you know, associated with every programming language compiler there is a program named recognizer that takes a string , say string S, as input and answers "YES" if S is a sentence of the language and " NO " otherwise. (a) DFA for {/abc/ ,/abd/}(b) DFA for /e. (C) Complement of every context-free language is recursive. However, the number of layers in the resulting DFA will be the product of 327 the number of layers in the two underlying DFAs. Approach : One simple method is to convert the binary number into its decimal representation and then check if it is a multiple of 3 or not. Homework 1 Solutions Note: These solutions are not necessarily model answers. E = 0 ∗ 10 ∗ ( 0 ∗ 10 ∗ 10 ∗ ) ∗ Now, let’s discuss that what strings should be accepted or rejected by our Regular Expression. Consider each row to be a binary number and let B {w the bottom row of w is the sum of the top two rows} For example, but is easier. Write a DFA with alphabet {0,1} that recognizes binary integers that have no useless (leading) zeroes and are not divisible by 2 or by 3. ) One can keep reading the binary sequence bit by bit, and maintain. As such, it may be said that the upper limit or “high watermark” for a number of DFA states of a CARPA-DFA is less than the number of DFA states of a typical DFA for the same pattern. It is your lesson for 24-03-2020. Figure (1) presents a DFA for this language; the existence of a DFA for the language establishes its regularity. The simplest one, using only state A, is: 0*. We begin by noticing that it is even, so we write a zero. Binary number 10110 is equivalent to 22 in decimal is not accepted i. Date and time of calculation 2017-09-22 13:55 UTC. C Program to Convert Binary to Decimal Number - In this tutorial, we will learn about how to create a program in C that converts any given binary number (by user at run-time) to its equivalent decimal value. To represent a real number in computers (or any hardware in general), we can define a fixed point number type simply by implicitly fixing the binary point to be at some position of a numeral. (The 1 + 1 because we divided the number 20 twice). (Only for DFA) Corresponding to each state, transition rule must be specified for each letter of the alphabet. That is, given two binary numbers, does the second one equal 2 times the ﬁrst one? For example, 11 2 = 22: 01011 10110 The input symbols are pairs of binary digits (00, 01, 10, 11), representing the columns. The following is an nfa that accepts L(abb) [L(abb). The result is in Figure 1d. As you scan the number, keep track of the count of even place 1's and odd place 1's. RegexPal isn't optimized for mobile devices yet. 2 Nondeterministic Finite Automata (or Accepter) De nition An NFA=(Q, , ,q0,F) where Q is nite set of states is tape (input) alphabet. From: Subject: =?utf-8?B?WWVuaSBkZcSfacWfZW4gw7xuaXZlcnNpdGUgc8SxbmF2xLEgeWVuaWRlbiBkZcSfacWfdGkuLi4gw5zDpyB5ZW5pbGlrIC0gQ3VtaHVyaXlldCBFxJ9pdGltIEhhYmVybGVyaQ. tomita4 Strings with fewer than 3 consecutive b’s. Construct an optimal DFA for A and prove its optimality by giving pairwise distinguishable strings, equal in number to the number of states in your DFA. Construct DFA that accepts strings contains even & odd combination of 0's and 1's - lecture14/toc - Duration: 9:34. How to Decode Binary Numbers. Let k be a positive integer. The easiest way is to create the NFA first and then convert it to DFA. Example Language Code The following DFA checks if the string over {0,1} contains even number of 1 or not:. Temporary Result: 10100011 New D=0 D=0, so we are done, and the decimal number 163 is equivalent to the binary number 10100011. Runs the lexing algorithm as a deterministic finite automata. 9 from textbook, p. Example - DFA for even binary numbers with an even number of ones. Login Now. of distinct binary trees possible with n labeled nodes? Solution$ \\frac{(2n)!} { (n+1)!}\$ (Proof to be Added) What is the no. So the product construction DFA we built has the fewest states possible. 6) Construct a DFA to accept all strings which satisfy #(x)mod5=2. You may assume the Show that B is regular. This means that abais in the language, because abacontains a single occurrence of aband a single occurrence of ba. Accepting states in the DFA are any DFA states that contain at least one accepting NFA state. There is no restriction on a number of zeros. This theorem will be a useful tool in designing DFAs, as well as in characterizing the regular languages. Give a regular expression for all binary numbers with an even number of 1's. S’ is the start symbol. Consider the following DFA D with: The finite set of states Q = {A, B}. This were written by several faculty. Numbers in Computers. you cannot store the string when it is provided, so the above method would not be applicable. Number of states require to accept string ends with 101. It runs in finite memory and has a complexity of O(1) but a slower run time and more memory usage than a tabular lexer. That is, given two binary numbers, does the second one equal 2 times the ﬁrst one? For example, 11 2 = 22: 01011 10110 The input symbols are pairs of binary digits (00, 01, 10, 11), representing the columns. Part c We saw a regular expression for a string containing an even number of occurrences of some symbol in lecture as well as on the homework. An Interactive Approach to Formal Languages and Automata with JFLAP Susan H. Even full “steer-by-wire” functionality has been seen in a range of concept cars including GM’s widely publicized Hy-wire fuel cell vehicle [12]. g: 01000101 01111000 01100001 01101101 01110000 01101100 01100101):. More info: State 1: even number of a's and even number of b's State 2: odd number of a's and even number of b's State 3: even number of a's and odd number of b's State 4: odd number of a's and odd number of b's. The state S 0 is both the start state and an accept state. , reading a new digit) multiplies the number by 2 and adds 0 or 1 according to that digit, so the DFA computes the congruence as it goes along. In the Settings > Advanced Settings window, set the "Windows Taskbar Split Monitor ID" option to whichever split number you want it to be on, then restart DisplayFusion. Now let’s create DFA for the above question. Now you need to construct the machine which is concatenation of the first DFA and the second DFA. Even though methods can be derived from them, they lack performance results and are only of theoretical interest. One can deﬁne a standard encoding of DFA as binary strings such that any DFA with N states is encodedas a binary string of length O lg. But theorem says the reverse of a regular language is also regular. Dividing by 2, we get 1. Sure, it runs in O(log n) time and it's more or less the best you can do to solve the general problem of finding something in a sorted list, but that does not mean it's a good way to create an immutable list of things that can be searched using comparisons. Figure 12: Question 15 2 1-7. Press button, get binaries. The maximum total number of points available is 32. 3 Prove that the following languages over the binary alphabet are regular: (2 pts) a. (0*10*1)*0* or 0*(10*10*)* or (0*10*10*)* h. Perl regular expression puzzle: even zeros and odd ones Greg Bacon [email protected] As a side not, binary numeral systems date back to BC days, I believe documented back to about 800BC or so if memory serves, and used as many (or few) digits as needed for the number to be represented; and the (similarly dated BC) Chinese binary systems used 3 digit and 6 digit groupings for their binary numbers. The set of all binary strings that contain at least one 0 and at least one 1. a)Binary number is EVEN: Ø When binary number ends with 0 ,it is always even/When the number is divisible by 2 i. remainder will be 0 and the state will be represented by q 0 Ø Since the number is even, q 0 will be final state. The initial state is E, and the ﬁnal state set is {O}. I know this is an old question, but an efficient answer is yet to be given and this question pops up first for "binary divisible by 3 regex" on Google. I could not fi. 2a in the text; 1. Click here to go back to the top of the page. Please note here we are talking about the node number and not the value in the nodes. To build this DFA, you must realize what happens upon s mod 5=0 when it is interpreted as a binary number (and begins with 1). , the number of. exe) and I'm confident that things are the way they should be now. \documentclass{article} \input{6045preamble} \usepackage{amssymb,amsmath,graphicx} \begin{document} \homework{2}{Prof. The state diagram for M M = ( Q , Σ , δ , q 0 , F ) {\displaystyle M=(Q,\Sigma ,\delta ,q_{0},F)} where. 7) Construct a DFA to accept all strings (0+1)* with an equal number of zeros and ones such that each prefix has at most one more zero than ones and at most one more one than zeros. Give the DFA accepting the language over the alphabet 0,1 that have the set of all strings ending in 00. ----- r901599 | jm | 2010-01-21 08:50:25 +0000 (Thu, 21 Jan 2010) | 1 line promotions validated ----- r901468 | jhardin | 2010-01-21 00:38:42 +0000 (Thu, 21 Jan 2010) | 1 line Do not publish the ADVANCE_FEE re-evolve test rules! ----- r901446 | mmartinec | 2010-01-20 23:54:29 +0000 (Wed, 20 Jan 2010) | 3 lines Bug 6295 RCVD_ILLEGAL_IP should not be eval rule - changing the rule itself. Here, two DFAs are called equivalent if they recognize the same regular language. DFA Construction Problems. Modern software allows the end user to ignore this, but at the lowest levels of your computer, everything is represented by a binary electrical signal that registers in one of two states: on or off. Give the DFA accepting the language over the alphabet 0,1 that have the set of all strings with 011 as a. Multiplying unsigned numbers in binary is quite easy. Call these two DFA’s M 1 and M 2 respectively. Let L= fwjw2 ;whas an odd number of as and starts and ends with a bg. Free Pascal Programmer’s Guide Programmer’s Guide for Free Pascal, Version 2. POP3: Post Office. {w| w starts with an aand has at most one b} 1A 1B 1C 2A 2B 2C 3A 3B 3C a a a,b a a a,b a a a b b b b b b b (f) i. Another example of a DFA: Strings in f0;1gwith an even number of 0s and an even number of 1s (H, Ex. g: 01000101 01111000 01100001 01101101 01110000 01101100 01100101):. (Hint: Working with BR result claimed in Problem 1. Languages (Finite State Machines) Carol Zander The DFA for signed binary numbers is larger, but still straightforward. 375 in decimal and binary systems the representation is the following: Converting decimal integer to binary # As it turns out, we can use this base-q expansion form to convert a number from decimal to binary system. Previous lecture: DFA details and example A DFA is an abstract machine with a finite number of states, each labelled Y or N and transitions between states, each labelled with a symbol. ) One can keep reading the binary sequence bit by bit, and maintain the intermediate result of the current parity in the working tape. Deterministic-Finite-Automata Applications CHAPTER4 35 We have seen how DFAs can be used to deﬁ ne formal languages. COS126 Regular Expressions, DFAs (Booksite 7. In addition to this formal use, DFAs have practical applications. (In general, there is a connection between small-est number of states of a DFA and the largest set. The exact language of binary strings of multiples of three representing the DFA is constructed. Means 110 in binary is equivalent to 6 in decimal and 6 is divisible by 3. The subset construction algorithm is also applied to the resultant NFA, resulting in a language-equivalent deterministic finite-state automata (DFA). Let's convert the number 46 to binary. Convert 110111111011 2 to hexadecimal | Convert 110111111011 2 to decimal | Convert 110111111011 2 to octal | Convert dfb 16 to Binary | Convert 3579 10 to Binary | Convert 6773 8 to Binary | Convert 110111111100 2 to hexadecimal | Convert 110111111100 2 to decimal | Convert 110111111100 2 to octal | Convert dfc 16 to Binary | Convert 3580 10. from Reddit tagged as Anaconda Meme. Let Abe a DFA and aa particular input symbol of A, such that for all states qof Awe have (q;a) = q. Sure, it runs in O(log n) time and it's more or less the best you can do to solve the general problem of finding something in a sorted list, but that does not mean it's a good way to create an immutable list of things that can be searched using comparisons. •Let Cn = {x | x is a binary number that is multiple of n}. Now plug a =2c back into the boxed equation 2 −4b. c) Divide D by 2. The only number facts to remember are that 0*1=0, and 1*1=1 (this is the same as a logical "and"). You just need states for 0, 1, 2, 3, 4, 5, A where 0 is the initial state and A is the single accepting state. Binary trees have an elegant recursive pointer structure, so they make a good introduction to recursive pointer algorithms. In particular, binary search has awful cache. Automata Theory Questions and Answers – Equivalence of NFA and DFA Under which of the following operation, NFA is not closed?. An embodiment of the invention may further comprise a system for splitting an automaton into a DFA portion and an NFA portion, comprising a DFA engine enabled to find matches to rules, an NFA engine, an NFA compiler enabled to compile a ruleset into an NFA representation, the compiler comprising a recursive entrance search function which is. There is no restriction on a number of zeros. Binary number 1111 is equivalent to 15 in decimal is accepted] 2 Design a DFA that accepts strings having an odd number of 1s and odd number of Os where alphabet is defined as 2 -10,1]. 1) Using Modulus operator(%) 2) Using Bitwise operator. However, the number of layers in the resulting DFA will be the product of 327 the number of layers in the two underlying DFAs. rows of Os and Is. Give the DFA accepting the language over the alphabet 0,1 that have the set of all strings ending in 00. For example, if we need to find the minimum number of states of a DFA which accepts all binary numbers divisible by 20, we do : 20/2 = 10 10/2 = 5 Hence our answer is 5 + 1 + 1 = 7. Construct a DFA that accepts the same language using the technique discussed in class. h Cube Data File Data File Handling Digits Display Even. , some number of zeros followed by an equal number of ones. A Binary String is even if it is ending with 0 and odd if its ending with 1. If the transtion function is defined for all States X Letters dfa3 Print the DFA dfa4 Check if a word is accepted by the DFA dfa5 If a word is accepted by DFA. Store it in some variable say num. To translate from binary to BCD, we can employ the shift-and-add-3 algorithm: Left-shift the (n-bit) binary number one bit. For each of the following, create a DFA that recognizes exactly the language given. Now plug a =2c back into the boxed equation 2 −4b. Let's do that for the same number 12. Its main task is to read the input characters and produce as output a sequence of tokens that the parser uses for syntax analysis. 5) Construct a DFA to accept all strings containing even number of zeros and even number of ones. 607 accepts_in_context (int prev, int curr, state_num state, struct dfa const *dfa). A formal inductive proof establishing that the DFA accepts L3 is beyond the scope of this question. That is, we will build a DFA that recognizes that language of any number of a's followed by any odd number of b's. Construct an optimal DFA for A and prove its optimality by giving pairwise distinguishable strings, equal in number to the number of states in. Write a regular expression for each of the following sets of binary strings. Show that if M is a DFA that recognizes language B, swapping the accept and non-accept states in M yields a new DFA recognizing the complement of B. A3: Let M be the language described as follows. Regular expression for the language of an odd number of 1’s is given below. 90) Let Σ={0,1} and let D={w|w contains an equal number of occurrences of the substrings 01 and 10}. If a string. We begin by noticing that it is even, so we write a zero. pumped) with the resulting string also being a member of the same regular language. dfa0 Describe a DFA dfa1 Check if DFA is well defined dfa2 Check if DFA or NFA. The state health department publishes online the number of confirmed cases for each census tract in the state. add 1 (one) to the result. In compliance with the National Telecommunications Commission's directive, the Department of Foreign Affairs trunkline numbers will be changed to an 8-digit phone number beginning October 6, 2019. Transition Diagram: M=(Q,Σ,δ,q0,F) = Tabular Format 0 1 q0 q1 Example of a move: δ(q0,1)= 2. The significand’s most significant digit is omitted and assumed to be 1, except for subnormal numbers which are marked by an all-0 exponent and allow a number range beyond the smallest numbers given in the. Such a graph is called a state transition diagram. [10 points] Solution: The following DFA with 5 states recognizes the language (as proved in HW 1). There are certain aspects of XML that have significant advantages in their own right and would be lost with a binary format. {w| w has at most one b} A B C a a a,b b b iii. In binary system, for any number such as 1011001, can we say directly "it is end with 1, so it is an odd number"?, or firstly Stack Exchange Network Stack Exchange network consists of 177 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. Design a DFA for the language that contains only binary strings in which the rst and last symbols are di erent. Example: DFA that accepts even binary numbers that have an even number of 1's. Give both a DFA and an RE for L. For example, if we need to find the minimum number of states of a DFA which accepts all binary numbers divisible by 20, we do : 20/2 = 10 10/2 = 5 Hence our answer is 5 + 1 + 1 = 7. The lexical analyzer is the first phase of compiler. Let Σ = {0,1}, and L be the language consisting of all strings over {0,1} containing a 1 in the kth position from the end (in particular, all strings of length less than k are not in L). •Let Cn = {x | x is a binary number that is multiple of n}. It is always convention to express binary numbers by using 4, 8, 32, or 64 binary digits even if the leading digits are zero. A computer number system that consists of 2 numerals, 0 and 1. {w| w starts with an aand has at most one b} 1A 1B 1C 2A 2B 2C 3A 3B 3C a a a,b a a a,b a a a b b b b b b b (f) i. This paper introduces multifractal detrended fluctuation analysis (MF-DFA) to analyze bearing vibration data and proposes a novel method for fault diagnosis of rolling bearings based on MF-DFA and Mahalanobis distance criterion (MDC). Trump among male voters, whites and people in middle age and older — groups that have typically been the backbones of Republican. What I had originally eliminated from the list was re-added (both are javaw. Nondeterminism gives a machine multiple We write DFA to specify a deterministic ﬁnite automaton (the An NFA that accepts all binary strings that end with 101. The parity is the number of occurrences of 1’s in the binary sequence modulo 2. “jalo re jalo” After generating the DFA table from tracing the algorithm and the DFA table state after running the algorithms both match. Do you know, associated with every programming language compiler there is a program named recognizer that takes a string , say string S, as input and answers "YES" if S is a sentence of the language and " NO " otherwise. {w| w has at most one b} A B C a a a,b b b iii. Obtain a DFA to accept strings of a’s and b’s having a sub string. This is a very simple example of a DFA, containing 2 states, S1 and S2, that have the language of [1,0], which means it accepts string consisting of 1s and 0s and accepts strings that have even. EXERCISES 1. You can see two looping paths from the start/final state back to itself by either a or ba*b. Approach : One simple method is to convert the binary number into its decimal representation and then check if it is a multiple of 3 or not. Design a DFA which checks whether the given binary number is even. Give both a DFA and an RE for L. remainder will be 0 and the state will be represented by q 0 Ø Since the number is even, q 0 will be final state. This is because ASCII was a 7 bit telecommunications standard first used by the Model 33 teletype. There are certain aspects of XML that have significant advantages in their own right and would be lost with a binary format. binary strings that contain a pair of 0s separated by two or more symbols;. They are directed graphs whose nodes are states and whose arcs are labeled by one or more symbols from some alphabet Σ. 1's complement of a binary number is the number that can be obtained by changing all ones to zeros and all zeros to ones of a given binary number. a number in decimal or binary system) such that X R (i. L(M 1) - L(M 2) represents all strings where the number of a’s is. ) One can keep reading the binary sequence bit by bit, and maintain the intermediate result of the current parity in the working tape. (The 1 + 1 because we divided the number 20 twice). tomita3 Strings with no odd number of consecutive b’s after an odd number of consecutive a’s. In what follows we are ignoring the unreachable states. Nondeterminism gives a machine multiple We write DFA to specify a deterministic ﬁnite automaton (the An NFA that accepts all binary strings that end with 101. It provides a middle road between the two other options. As we know that q1 indicates odd no. The transition. Example: Given 1->2->3->4->5->NULL,…. The number one is represented as 1 in both base ten and binary, so let's move on to the number two. Each digit is referred to as a bit. But the former vice president has also drawn even with Mr. The machine has one state for each of the four equivalency classes of. An Interactive Approach to Formal Languages and Automata with JFLAP Susan H. 3 Draw NFAs for the following languages, taking full advantage of nondeterminism: (2 pts) a. Due on Friday December 4, 2015 before 5pm (submit PDF on Markus) such that winterpreted as a binary number is divisible by 4. The idea is: use the shape of the DFA to store the finite history required to understand if you have read two ones or two zeros as the last two inputs. Let EVENDFA = fhDij D is a DFA and L(D) contains a word of even lengthg Prove that EVENDFA is decidable Reminder Deﬁne EDFA = fhDijD is a DFA and L(D) = ;g. De nition 1. How to Decode Binary Numbers. Construct a DFA that accepts the same language using the technique discussed in class. It is sometimes called base-2. Regular expression for the language of an odd number of 1’s is given below. The following ﬁgure shows an NFA for the language L 2. Orit Moskovich and Gal Rotem (TAU) Recitation 7 - R vs. L(M 1) - L(M 2) represents all strings where the number of a’s is. A DFA that accepts all binary strings containing an even number of 0s (but not ε). a) D is odd, put a 1 in the 27 column. For example, both 201100201 and 211 are in the language. We also talk about them being true and false. That is, come up with a family of languages L k such that L k can be recognized by a DFA with k states but not by a DFA with k − 1 states. This theorem will be a useful tool in designing DFAs, as well as in characterizing the regular languages. nth number, for example. Explanation. This is a very simple example of a DFA, containing 2 states, S1 and S2, that have the language of [1,0], which means it accepts string consisting of 1s and 0s and accepts strings that have even. Number of states require to accept string ends with 101. Parity bits are often used as a crude. y = 1 if and only if the current number multiplied by the previous number is divisible by 3. The alphabet is f0;1g. that can quickly estimate DFA size (i. S→ aS | λ | bB. Design DFA accepting binary strings divisible by a number 'n' (2) Below, I have written an answer for n equals to 5, but you can apply same approach to draw DFAs for any value of n and 'any positional number system' e. The state diagram for M M = ( Q , Σ , δ , q 0 , F ) {\displaystyle M=(Q,\Sigma ,\delta ,q_{0},F)} where. a)Binary number is EVEN: Ø When binary number ends with 0 ,it is always even/When the number is divisible by 2 i. DFA being learned is a canonical DFA. It is always convention to express binary numbers by using 4, 8, 32, or 64 binary digits even if the leading digits are zero. This blog will contain c programs related to interview preparation, basic programs, operating system, graphics, data structure, algorithms implementation, compiler and porjects. Example DFA, state replication, and Overlay DFA. Code Golf Stack Exchange is a site for recreational programming competitions, not general programming questions. We take sample numbers such as 4,8. It gets you from knowing basic programming to being a yellow-red rated coder on Codeforces / CodeChef / TopCoder / etc. Run: node dfa_even_zeros. Stanford CS Education Library: this article introduces the basic concepts of binary trees, and then works through a series of practice problems with solution code in C/C++ and Java. Create a DFA that recognizes strings with an even number of a’s and an even number of b’s Example – DFA for even binary numbers with an even number of ones Example: Build an NFA for valid integers. Go ahead and login, it'll take only a minute. S is the start state. {w| w starts with an aand has at most one b} 1A 1B 1C 2A 2B 2C 3A 3B 3C a a a,b a a a,b a a a b b b b b b b (f) i. Thus 101 ∈ D because 101 contains a single 01 and a single 10, but 1010 ! D because 1010 contains two 10s and only one 01. The set of all binary strings that contain at least one 0 and at least one 1. Im i right ? Thanks for contributing an answer to Mathematics Stack Exchange! Design DFA to check even number of 1s using 2 states. {w| w starts with an a} 1 2 3 a,b a,b b a ii. ∑ = { 0, 1 } Q = { S, even, odd }. Each position in a binary number represents a 0 power of the base (2). Yet this doesn’t necessarily mean that black holes suck matter in; they simply gravitate, and can remain in stable binary, trinary, or even larger star systems just fine. Hard to construct the DFA. work internally by using the binary number system. If a relation is equivalence then it must be i) Symmetric ii) Reflexive iii) Transitive If a relation is partial order relation then it must be i) Reflexive ii) Anti-symmetric iii. Press button, get binaries. Introduction. Finite state machines can be used to model problems in many fields including mathematics, artificial intelligence, games, and. Now let’s create DFA for the above question. Machine learning systems are cheaper to train now than ever before. Initially the input tape contains the number n in unary notation (alphabet: {1}). a number in decimal or binary system) such that X R (i. • NFA’s are usually easier to “program” in. Also construct an NFA for the language L 3 that has at most 7 states. Draw a ﬂnite automata for L = fwj w contains 101 as a substringg. Design DFA accepting binary strings divisible by a number 'n' (2) Below, I have written an answer for n equals to 5, but you can apply same approach to draw DFAs for any value of n and 'any positional number system' e. (c) all strings with an even number of a’s. There are 3 inputs x0x1x2 which represent a 3 digit binary number. Nancy Lynch}{Due: Tuesday, February 20, 2007. For Σ = {a, b}, construct dfa’s that accept the sets consisting of (a) all strings of even length. In the Settings > Advanced Settings window, set the "Windows Taskbar Split Monitor ID" option to whichever split number you want it to be on, then restart DisplayFusion. Fixed Point Number Representation. Call these two DFA’s M 1 and M 2 respectively. This instruct. Address: Aseana Business Park, Pres. The second parses any string which has an even number of a and an even number of b, again by taking characters in pairs: if it sees an aa or a bb it continues, otherwise if it sees an ab or a ba it skips as many aa and bb tokens as it can until it finds a corresponding ab or ba (doesn't matter which). i occurs an even number of times (not necessarily consecutively), where 1 ≤ i ≤ m. Convert the NFA in 2f into a DFA. When set to true all nonzero frequency counts are set to 1. A General Approach to DFA Construction. Also construct an NFA for the language L 3 that has at most 7 states. For example, we find that 29 is Prime - because it cant be e. The transition. Example: Binary Number Divisible by 7 9 Objective: Write a DFA 𝐷where Σ=0,1and 𝐿𝐷={𝑥| when interpreted as a binary number, 𝑥is evenly divisible by 7}. In this program, you'll learn to convert binary number to a decimal number and vice-versa using functions in Java. ph DFA Office of the Consular Affairs. The following ﬁgure shows an NFA for the language L 2. A context-free grammar (CFG) is a set of recursive rewriting rules (or productions) used to generate patterns of strings. dfa) Write a DFA that recognizes a decimal number between -128 and 127 inclusive, with no useless zeroes. Even though CAD tools are used to create combinational logic circuits in practice, it is important that a digital designer should learn how to generate a logic circuit from a specification. Hence, we observe that for numbers to be divisible by 4, the last two bits should be 0, because if both of them or either of them becomes 1, the sum of those two bits in decimal wouldn't be divisible by 4. Derive a regular expression to describe all binary strings with even parity (those with an even number of 1’s) by performing the following steps: Draw the DFA from class that recognizes binary strings with even parity, and then convert this DFA into a regular expression using the process described in the book (pages 69–73). Each position in a binary number represents a 0 power of the base (2). Describe a machine that accepts even binary non-negative. from Reddit tagged as Anaconda Meme. If a number is exactly divisible by 2 then its an even number else it is an odd number. The easiest way is to create the NFA first and then convert it to DFA. There are in addition the following errors that are specific to pcre_dfa_exec(): PCRE_ERROR_DFA_UITEM (-16). Such a graph is called a state transition diagram. , the number of. By simulating binary division, we create a DFA M with n states that recognizes Cn. Name your electronic file username_cs357_hwX. We take sample numbers such as 4,8. tomita5 Strings with even length with an even number of a’s. There is no restriction on a number of zeros. Input File For DFA Program: 1 3 2 3 2 4 1 5 2 5 5 5# 0 1 4 For more C programs related to Automata, Check Automata label. Here Σ is {0,1}. O STOICHIOMETRY Elemental analysis of binary compounds Measurements show that unknown compound I has the following composition: element mass o zinc />. For Σ = {a, b}, construct dfa’s that accept the sets consisting of (a) all strings of even length. We eventually end up with the DFA below as before: {1,2} {2,3} ∅ a {1,2,3} b a b a,b b a Forthe DFAstate ∅, there are noversions ofthe NFAcurrently active, i. Logic to count zeros and ones in a binary number. Similar to binary in performance, but uses a strict ByteString instead of a lazy ByteString, thus. You may assume the Show that B is regular. C Programming Code to Get Input from User Following C program ask to the user to enter a number to get the number entered by the user, then display the entered number on the screen The function scanf() in C is used to scan the input data like integer, character, float, etc. Programs to recognise languages accepted by DFAs are very efﬁcient. 1007/978-3-030-42051-2 https://doi. 2 Nondeterministic Finite Automata (or Accepter) De nition An NFA=(Q, , ,q0,F) where Q is nite set of states is tape (input) alphabet. pdf or username_cs357_hwX. (5m )( Jun-Jul 11)(Ju n-Jul12) 9. bit string interpreted as binary number is divisible by 3 bit string interpreted as binary number is divisible by 123 Boston accent. Each position in a binary number represents a 0 power of the base (2). It provides a middle road between the two other options. Below is a what information is stored in each state in above DFA. (i) What is L(M 1) - L(M 2). A DFA can be. Explanation: The out degree for a DFA I fixed while the in degree depends on the number of states in the DFA and that cannot be determined without the dependence over the Language. Therefore, what follows is the DFA for the simpler language of fw2f0;1g : whas an even lengthg. Show that for each n >= 1, the language Cn is regular. Give the state diagram of a DFA that recognizes the language fw j w contains an equal number of occurrences of the substrings 01 and 01g. Example Language Code The following DFA checks if the string over {0,1} contains even number of 1 or not:. Every DFA-acceptable language can be accepted by a DFA with an even number of states. Recall the DFA Dwe constructed that accepts a binary string i it has an odd number of 1’s: 0 1!A A B B B A (a) Convert Dinto an equivalent clean -NFA using the clean-up procedure in class (add a new start state, a new nal state, and some -transitions). Rather, they are designed to be tutorial in nature, and sometimes contain a little more explanation than an ideal solution. Exercise 2. Which of the strings 0001, 01101, 00001101 are accepted by the dfa in Figure 2. We get (2 c) 2 −4 b=2, so. Moves down when column number is 0 and column number is odd. What language (or set of strings) is accepted by the following DFA?. Figure 12: Question 15 2 1-7. The transitions of the DFA tell us δ-hat(A,w) = A. For a binary number to be divisible by 3, the binary number should have the same number of 1s in odd positions as number of 1s in even positions, which implies that it should also contain and even number of 1s. And in general this could be applied. The disadvantage of bit arithmetic example is that it contains conversion of int to unsigned int and if the computer uses the 1's complement system or the sign and magnitude system, the final result is incorrect. This DFA computes the congruence mod 5 of the number as you read it from left to right: adding a binary digit on the right (i. Automata Theory Questions and Answers – Equivalence of NFA and DFA Under which of the following operation, NFA is not closed?. tomita6 Strings where the difference between the number of a’s and b’s is a multiple of 3. a DFA for this language. This blog is to help the people who are preparing for UGC NET on the subject Computer Science and Application. To use this calculator, simply type the value in any box at left. Example 1: DFA for Binary Strings with an Even Number of 0's. Go ahead and login, it'll take only a minute. We take sample numbers such as 4,8. Please note here we are talking about the node number and not the value in the nodes. Dfa Divisible By 3. , all "threads". ∑ = { 0, 1 } Q = { S, even, odd }. Show that for each n >= 1, the language Cn is regular. CountVectorizer converts text documents to vectors of term counts. In addition to this formal use, DFAs have practical applications. Diosdado Macapagal Avenue corner Bradco Avenue. The adjacency operator A and its eigenvalues. Create a DFA that accepts binary numbers that are divisible by 4 (mod 4) using thin JFlap. from Reddit tagged as Anaconda Meme. So for example: if we have 4 bits to represent a signed binary number, (1-bit for the Sign bit and 3-bits for the Magnitude bits), then the actual range of numbers we can represent in sign. good ones nonevent tentative to solve number 1. Initially the input tape contains the number n in unary notation (alphabet: {1}). nolds module¶. Convert 13 10 to binary:. Let (S,q0,T,F) be a DFA. Begin in the start state. canonical DFA. You can achieve this by pointing all the Final/Accept states from the first DFA to the start state of the second DFA using e moves (empty moves) as shown below. In this lesson, we will discuss in detail and find answers to some important topics in binary number system. The machine should give 1 as output if an even number of 1's are in the string and 0 otherwise. In the theory of computation, a branch of theoretical computer science, a deterministic finite automaton (DFA)—also known as deterministic finite acceptor (DFA), deterministic finite-state machine (DFSM), or deterministic finite-state automaton (DFSA)—is a finite-state machine that accepts or rejects a given string of symbols, by running through a state sequence uniquely determined by the. Prove that F is decidable. Nondeterminism gives a machine multiple We write DFA to specify a deterministic ﬁnite automaton (the An NFA that accepts all binary strings that end with 101. The machine should give 1 as output if an even number of 1's are in the string and 0 otherwise. L0 = {binary numbers divisible by 2}\爀 䰀㄀ 㴀 笀戀椀渀愀爀礀 渀甀洀戀攀爀猀 搀椀瘀椀猀椀戀氀攀 戀礀 ㌀紀屲 L2 = {x | x ∈ {0,1}*, x\ഠdoes not contain 000 as a substring}. i occurs an even number of times (not necessarily consecutively), where 1 ≤ i ≤ m. Example #1. If a string starts with a 0, then it ends with a 1. Steps for building a DFA to recognize L: Σ = {0,1} Decide on the states: Q Designate start state and final state(s) δ: Decide on the transitions: 10 11. Even full “steer-by-wire” functionality has been seen in a range of concept cars including GM’s widely publicized Hy-wire fuel cell vehicle [12]. Give a DFA for L with at most four states. Prerequisite - Designing finite automata Problem - Construct a DFA machine over input alphabet = {0, 1}, that accepts: Odd number of 0's or even number of 1's Odd number of 0's and even number of 1's Either odd number of 0's or even number of 1's but not the both together. 4(a): Given a DFA that accepts the set of all binary strings ending in 00. q0 q1 q2 0 q3 1 0 0 1 1 0 1 The language fw2f0;1g jwcontains an even number of 0s, or exactly two 1sgwith six states or fewer. The empty string is in M. The shifting process above is the key to understand fixed point number representation. We'll soon see the construction of a RE from a DFA, but this one is easy. Is it possible to construct a DFA(Deterministic Finite Automata) that will accept binary numbers that are divisible by 5 but in reverse? For example, the automaton should accept 00101 because it is 10100 in reverse, which is 20 in decimal, which is divisble by 5. (The 1 + 1 because we divided the number 20 twice). CPS 220 – Theory of Computation Non-regular Languages Warm up Problem Problem #1. Answer: let M' be the DFA M with the accept and non-accept states swapped.