0

A couple homework problems that I've been working on, hoping I can get it done right. Can anyone confirm if my line of reasoning and regex is correct?


L = { $w \in $ {$x, y$}* | $w$ contains a maximum one instance of $xx$ }

My answer $$ ((y^*+x)^2)y^*$$

This ticks off $y, x, xx, yx, xy, yyy$, but won't allow more than one $xx$. Only issue I could find is that it doesn't allow $yxyxy$ and the like. Any tips on how to overcome this on a larger scale? Don't know if $$ (((y^*+x)^2)y^*)^*$$ is cheating, also considering that you can have $xxxx$ from that Thoughts?


L = { $w \in $ {$0, 1$}* | $w$ does not have any instances of $011$ }

My answer

$$(0^*1)^* + 1^*0^*$$

This allows $0, 01, 1, 10, 001$, etc. The only issue I seem to find is that it does not allow $00101$. Almost the same issue as last one, any ideas on how to overcome these?

  • 1
    I would start with a finite state automaton and translate to regex. – Hendrik Jan Nov 22 '15 at 02:28
  • We haven't done finite state automat(i)on(?). Could you possible explain the finite state of #1 so I can apply it? – Andrew Raleigh Nov 22 '15 at 02:53
  • OK. Then I would start at "no instances of $xx$" – Hendrik Jan Nov 22 '15 at 03:14
  • Your question is a very basic one. Let me direct you towards our reference questions which cover your problem in detail, especially http://meta.cs.stackexchange.com/a/843/755. Please work through the related questions listed there, try to solve your problem again and edit to include your attempts along with the specific problems you encountered. – D.W. Nov 22 '15 at 03:23
  • A couple of other notes for future reference: we want you to ask only one question per question. The site format doesn't work for multiple questions (it discourages people who only know how to answer one of your two questions.) Also, I'm not sure why you're asking someone to confirm whether your answer is right when it appears you know it is incorrect. We generally iscourage "please check whether my answer is correct" questions, for a variety of reasons. – D.W. Nov 22 '15 at 03:24

0 Answers0