but "100", 110000", "000", "111" is not contained in L.
∂(q0, 1) = q0
∂(q1, 0) = q1
∂(q1, 1) = q2
∂(q2, 0) = q2
∂(q2, 1) = q2

Now what if we try and modify it and say we want it to accept any string containing the string "0101"
Problem 2: Design a DFSA that accepts a string that has the sequence "0101" somewhere in the string
So our state transition table will change and we have to introduce new states q3 and a final accepting state q4. So if we start at q0 and find a "1", its pretty useless and we remain in the same state q0. but if we find a "0" means that it is the start of the substring we are looking for. So we jump to state q1. Now from q1, if we find a "0" as the next character, we are back to square 1 so we jump back to q0. But if we find a 1, we jump to q2. Similarly, if we get a "0" while being in state q3, its useless since its not forming the substring we are looking for and we jump back to q0. But if we find a "1", then we jump to the final accepting state q4. Once we are in state q4, we 'dont care' about the incoming characters since we have already found our substring and we remain in state q4.
So our transition table becomes:
∂(q0, 1) = q0 ---------- ∂(q0, 0) = q1
∂(q1, 0) = q0 ---------- ∂(q1, 1) = q2
∂(q2, 0) = q3 ---------- ∂(q2, 1) = q0
∂(q3, 0) = q0 ---------- ∂(q3, 1) = q4
∂(q4, 0) = q4 ---------- ∂(q4, 1) = q4
And our state diagram would look like this:

I must thank Danny for showing us jFlap. Its a great tool to analyse state diagrams and find flaws.
1 comment:
bezer, fini, mone gate mo la zournee! :S
tone traumatise mwa la lol!
Post a Comment