convert NFA to regular expression and tell whether it is multiple of 3?

StackOverflow https://stackoverflow.com/questions/23213695

  •  07-07-2023
  •  | 
  •  

سؤال

i am doing practice and just want to confirm whether i have correctly made the expression and recognize the expression as a multiple of 3?

enter image description here

is that correct expression and my answer:
 ((aaa)* + (bbb)*) 
 expression shows a string length multiple of 3
هل كانت مفيدة؟

المحلول

Yes, your regular expression is correct, language defined by the NFA in picture either accepts null string ^ or (aaa)+ or (bbb)+. You have covered ^ in * closure.

If you wants you can make its DFA something like as below:

     __ bbb          __ aaa  
     ||              ||
     ▼|              ▼|
--►((Q0))---aaa---►((Q1))

Where both Q0 and Q1 are final states (Q0 is start state).

side note: you can replace edge labels of 'aaa' to 'bbb' and 'bbb' to 'aaa' to get another form of same DFA. Additionally, in standard form of DFA an edge lable can be single language symbol.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top