简体   繁体   中英

Transition State Diagram for the automata

What will be the transition state diagram of (a+b)* and (ab)* ? I'm little confused with the two state diagrams. I'm finding both of them same.

Assume the teal-colored states are start and accept states. (a+b)* can be read as "zero or many a's and b's in any order." (ab)* can be read as "zero or many a's and b's in sequence." Note that node 3 exists as a dead state to reject a match if the sequence is broken. 在此处输入图片说明

Assuming + means union and . means concatenation:

(a+b)*
q   s   q'
--  --  --
q0  a   q0
q0  b   q0
(q0 is accepting)

(a.b)*
q   s   q'
--  --  --
q0  a   q1
q0  b   q2
q1  a   q2
q1  b   q0
q2  a   q2
q2  b   q2
(q0 is accepting; q2 is a dead state)

Note that (a+b)* describes all strings of a's and b's, so we only need one state; no strings are rejected. On the other hand, there are strings of a's and b's that don't match (ab)*; we end up with three states because:

  1. If we've seen an integer number of "ab", we can see nothing or another integer number of "ab" (corresponds to state q0)

  2. If we've seen an integer number of "ab" followed by an "a", we can see a "b" followed by an integer number of "ab" (corresponds to state q1)

  3. If we've seen something besides what we discuss in points 1 and 2, there's nothing we can add to the string to get an integer number of "ab"; we've messed up, and any string with this prefix is not in the language (corresponds to the "dead" state q2).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM