-3

I am really new to this and to sure how to start. I am trying to do this question for practice

Let segma = {a,b}. Consider the set of all strings in segma* that have an odd number of occurrences of the substring "ab" but do not have "bb" as a substring. Give a DFA with six states accepting the set.

I did change my solution.

Attempt

Alex
  • 23
  • 1
  • 6
  • 1
    Why don't you give it a try, and then see if you end up with six states? – Jason Baker Nov 13 '14 at 03:36
  • @JasonBaker. I did try but I am not sure how to start, that is why I put this question. – Alex Nov 13 '14 at 03:40
  • I hav made this solution and not sure if I am in the right track or not http://s4.postimg.org/3wdpz9bv1/Screen_Shot_2014_11_14_at_9_38_59_PM.png Please any suggestions – Alex Nov 15 '14 at 03:55

1 Answers1

0

Here is an idea of how to approach this question. Think about the conditions you need to meet.

First, you need to have an odd number of "ab", which means your DFA should have a "counter" loop that every time you encounter odd number of "ab", your DFA will be in a state, such that this state has an edge that allows your DFA to move toward the accepting state. Conversely every time you encounter even number of "ab", your DFA should be in a state, such that this state cannot move forward, unless you encounter another "ab".

Second, the string cannot have "bb". This means that if you ever encounter a single "b", a subsequent "b" will drive your DFA to a sink, which means your DFA rejects the string.

It might be easier to associate each character condition to the edges, so that if a certain condition is met, your DFA can move to a certain state.

StoneBird
  • 1,900
  • 13
  • 12
  • Thanks. This is really helpful. I will try do as you suggested and I will post my solution to see if I need to fix it – Alex Nov 13 '14 at 04:09
  • I did solution and I am not sure if that is correct. Please check the link http://s4.postimg.org/3wdpz9bv1/Screen_Shot_2014_11_14_at_9_38_59_PM.png – Alex Nov 15 '14 at 03:41
  • @Alex I don't think your solution is correct. Try passing in "bab" to your DFA and see which state can you end up with. Currently it doesn't even pass the start state. Meanwhile you can use several other strings to test your DFA. e.g. "babab" "bababab" "abbb" "abaabab" "aaaaaaaaaabaababb"... – StoneBird Nov 16 '14 at 03:26
  • I did modify my solution. I hope you can look at it – Alex Nov 18 '14 at 07:23
  • @Alex makes much more sense to me. I think this one works well. Did you check other strings? – StoneBird Nov 18 '14 at 16:32
  • thanks for helping me. I did check different strings. I would appreciate if you give me more examples. I might thinking of similar as you gave me – Alex Nov 18 '14 at 16:44
  • @Alex check this little Python code. It creates 10 strings of max length 20 at random. Hope it helps. https://gist.github.com/StoneBird/82ebdb05dddde2b258bd#file-random-dfa-string-generator – StoneBird Nov 18 '14 at 23:51