nfa - Regex Pattern to Match Certain Rules -


update: turns out idiot , misread original problem. original problems specifies there must @ 3 of 4 letters used, not @ least. changes question , eliminates doubts when creating nfa , dfa. sorry , help!

for homework problem, have create regex pattern match these specifications...

  • must composed of letters a, b, c, , d
  • must in reverse alphabetical order
  • must use @ least 3 of 4 given letters (a,b,c,d is, can have many total letters possible)

my answer confident (d+c+b+a*)|(d+b+a+)|(d+c+a+)|(c+b+a+). first question if correct. second if expression can simplified or altered @ all.

the next step draw graph non-deterministic finite automaton regex , having difficulty completing step.

as requested, here attempt @ nfa (rough sketch)

enter image description here

your answer fine me.

there 5 kinds of patterns match:

d+c+b+a+ c+b+a+ d+b+a+ d+c+a+ d+c+b+ 

(d+c+b+a+)|(c+b+a+)|(d+b+a+)|(d+c+a+)|(d+c+b+),which in following forms merging first pattern sub-fours:

(d+c+b+a*)|(d+b+a+)|(d+c+a+)|(c+b+a+) or (d*c+b+a+)|(d+b+a+)|(d+c+a+)|(d+c+b+) ... 

a quite straight forward way me:

(d*c+b+a+)|(d+c*b+a+)|(d+c+b*a+)|(d+c+b+a*) 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -