Regular Expressions

What regular expression is represented by the finite state machines shown below? ( S 0 (S_0 is the starting state. ) )

( a b a ) ( c d c ) (ab*a)*\mid (cd*c)* ( a b a c d c ) (ab*a \mid cd*c)* a b a c d c aba \mid cdc ( a b a c d c ) (aba\mid cdc)*

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Karleigh Moore
Jun 21, 2016

The answer is ( a b a c d c ) (ab^*a | cd^*c)^* .

S 0 S_0 is the starting state and the accepting state. From the starting state we can either choose "c" or "a" to transition to S 1 S_1 or S 2 S_2 , respectively. This clues us into the fact that the answer will probably have an "OR" operation.

Case 1: we go to S 1 S_1 and generate a "c". From S 1 S_1 to get back to the accepting state ( S 0 S_0 ), we can go straight to S 0 S_0 with a "c" transition, generating the string "cc" or we can loop back in on S 1 S_1 with "d" however many times and then do the "c" transition to the accepting state, generating a string with a "c", then any number of "d"s, then one "c".

Case 2: we go to S 2 S_2 and generate an "a". From S 2 S_2 to get back to the accepting state ( S 0 S_0 ), we can go straight to S 0 S_0 with an "a" transition, generating the string "aa" or we can loop back in on S 2 S_2 with "b" however many times and then do the "a" transition to the accepting state, generating a string with an "a" then any number of "b"s and then an "a".

After we complete either case 1 or case 2, we can start the whole thing over and add on another part of the string using case 1 or 2, and this is why there is a star surrounding the OR term.

For example, we could complete case 1 with 2 iterations of "d" to make "cddc" and then back at q 0 q_0 , we could do a case 2 with three iterations of the "b" transition to produce the string "cddcabbba".

Why is (ab a) l (cd c) different from (ab a l cd c)*? As far as I can tell you get the same answer for all given strings. The empty string is possible, as well as any combination of the two paths. Edit: By chance I stumbled upon my problem again. The former one does not let you choose between both options for ever. If you chose one you are stuck with it. The second one iteratively asks wether you want to go left or right.

Walter Ehrenberger - 2 years, 5 months ago

(aba|cdc)* basically says that either can follow the other or itself any number of times. So it could abacdcaba or abaabaabacdccdcaba or any combination of the two following each other or themselves.

Kevin Flores-Ortiz - 1 year, 7 months ago

I don't understand the solution. It's possible to get "ccaa" from the machine. Start from s0 > s1 > s0 > s2 > s0

David Chen - 1 year, 4 months ago

Log in to reply

Yeah, i think its supposed to be (ab a | cd c)*

Rens Vester - 11 months, 2 weeks ago

The asterisk b* meana that b is repeated 0 -> infinity times. ab*a can then also give aa.

Odin Østvedt - 7 months, 1 week ago

Whats the difference betweeen (ab a) |(cd c) and (ab a|cd c)* ? The first option wil makes it possible to repeat (ab*a) any number of times before we go on to the other part of the or expression, is that why its a wrong description?

Odin Østvedt - 7 months, 1 week ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...