human
Program to construct DFA for Regular Expression C ( A + B ) + | Function to find whether the given is Accepted by the DFA.
If n <= 1 , then prNo.
To count the matched characters.
Check if the first character is C.
Traverse the rest of string.
If character is A or B , increment count by 1.
If the first character is not C , pr - 1.
If all characters matches.
Driver Code"
Solution in Python:
assistant
#Here is code to program to construct DFA for Regular Expression C ( A + B ) + and the other steps required.
 def DFA ( str , N ) :
	if ( N <= 1 ) :
		print ( " No " )
		return
	count = 0
	if ( str [ 0 ] == ' C ' ) :
		count += 1
		for i in range ( 1 , N ) :
			if ( str [ i ] == ' A ' or str [ i ] == ' B ' ) :
				count += 1
			else :
				break
	else :
		print ( " No " )
		return
	if ( count == N ) :
		print ( " Yes " )
	else :
		print ( " No " )
if __name__ == ' _ _ main _ _ ' :
	str = " CAABBAAB "
	N = len ( str )
	DFA ( str , N )