What will be the DFA for the regular expression 0(0+1)*0+1(0+1)*1?
Asked Answered
R

2

2

This is the DFA i have drawn-

MyDFA

Is it correct?
I am confused because q4 state has 2 different transitions for same input symbol which violates the rule of DFA, but I can't think of any other solution.

Republic answered 2/1, 2013 at 13:15 Comment(3)
See also this question .Grenadine
chirs view my updated answer I corrected DFAGrenadine
Determinicy refers to the fact that it is not allowed to have two outgoing transitions with the same label from the same state. It does not refer to incomming transitions.Sanders
G
4

Your DFA is not correct.
your DFA is completely wrong so I don't comment

DFA for RE:

0(1 + 0)*0 + 1(1 + 0)*1  

Language Description: if string start with 0 it should end with 0 or if string start with 1 it should end with 1. hence two final states (state-5, state-4).

state-4 : accepts 1(1 + 0)*1
state-5 : accepts 0(1 + 0)*0
state-1 : start state.

DFA:

DFA

EDIT :

+ Operator in Regular Expression

(0 + 1)* = (1 + 0)* that is any string consist of 1s and 0s, including Null string ^.

Here + means Union if it appear between two RE: and A U B = B U A (similarly)=> (0 + 1) = (0 + 1) .

meaning of plus + depends on syntax it appears in: If expression is a+ (+ is superscripted) this means one of more as, and If a+b then + means Union operation either a or b.

a+ : { a, aa, aaa, aaa.....} that is any number of a string in language with length > 1.

Grenadine answered 2/1, 2013 at 14:18 Comment(10)
I believe it is 0(0+1)*0+1(0+1)*1 instead of 0(1 + 0)*0 + 1(1 + 0)*1Michelinemichell
@HélioSantos Is there any difference?Republic
yes, its a regular expression, not a math expression. (0+1) => one or more zeroes followed by a one (1+0) => one or more one followed by a zeroMichelinemichell
@HélioSantos Yes it is a regular expression. I think (0+1)* means any number of zeroes and ones, same as (1+0)* . From your point, my regular expression doesnot accept 0010, but it does.Republic
@Republic that would be [01]* any number of zeroes OR ones (01|10)* any number of the combination 01 OR 10. Try here(rubular.com). Which regex implementation are you using?Michelinemichell
@HélioSantos (0 + 1)* means any string consist of 0s and 1s including ^ and (O+1)* = (1+0)*. Actually + means Union and A U B = B U A.Grenadine
@GrijeshChauhan + is a quantifier. The element before + should appear one or more times (regular-expressions.info/repeat.html). Are we talking about the same thing - regex??Michelinemichell
@HélioSantos meaning of plus depends on syntax it appears if expression is a+ this means one of more as and if a+b then + means Union operation either a or b.Grenadine
@HélioSantos + in Regular ExpressionGrenadine
@HélioSantos Welcome your! :)Grenadine
R
0

I think you should start with 0 first

0(1 + 0)*0 + 1(1 + 0)*1

enter image description here

Ramey answered 8/11, 2018 at 6:4 Comment(1)
Welcome to Stack Overflow! Generally, answers are much more helpful if they include an explanation of what the code (or formula) is intended to do, and why that solves the problem without introducing others.Nu

© 2022 - 2024 — McMap. All rights reserved.