Question

In: Computer Science

Construct a dfa that accepts strings on {0, 1} if and only if the value of...

  1. Construct a dfa that accepts strings on {0, 1} if and only if the value of the string, interpreted as a binary representation of an integer, is zero modulo five. For example, 0101 and 1111, representing the integers 5 and 15, respectively, are to be accepted.

Solutions

Expert Solution

Here is procedure to build this dfa :

  • To build this DFA, you must realize what happens upon reading a new character in terms of multiplication.
  • If we are adding a 0 , it means we are multiplying our current number by 2 (this is a left shift operation). If we are adding a 1 , it means we are multiplying our current by 2 and adding 1.
  • To make sure it is divisible by 5, we have to operate mod 5 and we should accept s only when s mod 5 = 0 when it is interpreted as a binary number(and it begins with 1)
  • We also have to construct seperate states for start and 0 mod 5. This is why because if they are same states then we would go to trap state after reading a 0.
  • But if we already read part of string that started with 1 and which was equivalent to 0 mod 5 then our DFA would trap but it should not. Thus, two states should need to be made(S and 0 in the below diagram) to prevent this error from occuring.

DFA :

Like, if this helped :)


Related Solutions

Consider the number of strings on {0, 1} defined by the requirement below. For each construct...
Consider the number of strings on {0, 1} defined by the requirement below. For each construct a dfa. Every 00 is followed by a 1. For example, the strings 101, 0010, 0010011001 are in the language, but 0001 and 00100 are not. The leftmost symbol differs from the rightmost one.
Automata Question. Over the alphabet Σ = {a, b}: 1) Give a DFA, M1, that accepts...
Automata Question. Over the alphabet Σ = {a, b}: 1) Give a DFA, M1, that accepts a Language L1 = { w | w has exactly 2 a’s } 2) Give a DFA, M2, that accepts a Language L2 = { w | w has at least 2 b’s } 3) Give acceptor for L1 intersection L2 4) Give acceptor for L1 - L2
Write a progrm that accepts two strings as input, then indicates if the two strings are...
Write a progrm that accepts two strings as input, then indicates if the two strings are equal when the case of individual letters is ignored. Sample runs are shown below. Use C++ Enter two strings. String 1: PROgraM String 2: proGram PROgraM and proGram are equal. Enter two strings. String 1: litter String 2: LittLe litter and LittLe are not equal.
Q5 [15 pts] a) Convert the following NFA to a DFA: 0 1 ---------------------- -> a...
Q5 [15 pts] a) Convert the following NFA to a DFA: 0 1 ---------------------- -> a || {a} | {a,b} b || {c} | {c} c || {d} | {d} d || {e} | {e} * e || {} | {} b) Informally describe the language that it accepts.
Create a DFA for L = {wwR|w ∈ {0, 1}∗}. WR represents the reverse of the...
Create a DFA for L = {wwR|w ∈ {0, 1}∗}. WR represents the reverse of the string. Explain your answer.
Construct a finite-state machine, using combinational logic for an apple vending machine that only accepts nickels...
Construct a finite-state machine, using combinational logic for an apple vending machine that only accepts nickels (5 cents). When 15 cents is deposited the user can push a button to receive an apple and the machine resets. If the user inserts more than 15 cents no money will be returned. What are the machine states? What are the inputs? What are the outputs? Draw state table Draw state diagram Write the combinational logic for next state and output Explain if...
construct a DFA to check if a string containing a,b and no.of a's is divisible by...
construct a DFA to check if a string containing a,b and no.of a's is divisible by 5 and no.of b's is divisible by 7
Write an application that accepts up to 20 Strings, or fewer if the user enters the...
Write an application that accepts up to 20 Strings, or fewer if the user enters the terminating value ZZZ. Store each String in one of two lists—one list for short Strings that are 10 characters or fewer and another list for long Strings that are 11 characters or more. After data entry is complete, prompt the user to enter which type of String to display, and then output the correct list. For this exercise, you can assume that if the...
Construct NFA of following languages and convert it to equivalent DFA. The set of all binary...
Construct NFA of following languages and convert it to equivalent DFA. The set of all binary strings such that 3th symbol from right end is 0.
Given two DFAs, A and B, show that you can construct a DFA C such that...
Given two DFAs, A and B, show that you can construct a DFA C such that L(C) = ∅ if and only if L(A) ⊆ L(B). Prove that your construction works by proving the if and only if statement.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT