\documentclass[12pt]{exam}
\setlength{\topmargin}{0.25in}
\renewcommand{\solutiontitle}{\noindent\textbf{Answer:}\par\noindent}
\pagestyle{headandfoot}
\header{CS 460/660}{Handout WA1}{}
\footrule
\headrule
\footer{}{Page \thepage\ of \numpages}
  {\iflastpage{End of Assignment}{Please go on to the next page\ldots}}
  
  \usepackage{graphicx}
%\printanswers

\begin{document}


This assignment asks you to prepare written answers to questions on
regular languages and finite automata.  Each question has a short
answer.  You may discuss this assignment with other students and work
the problems together.  However, your writeup should be your own
individual work.  Remember written assignments are to be turned in in
class on the date due.

\begin{questions}

\question
	Write regular expressions for the following languages:
		\begin{parts}
		\part[2] All strings of $a's$ and $b's$ that do not include
			the substring $ab$.
			\begin{solution}
			\verb@b*a*@
			\end{solution}
		\part[2] All strings of $a's$ and $b's$ that do not include
			the substring $aba$
			\begin{solution}
			\verb@b*(a|bb+)*@
			\end{solution}
		\part[2] All strings of digits where every 3rd digit
			(starting with the first digit) is even.
			\begin{solution}
			\verb@E={0,2,4,6,8}@ \\
			\verb@I={0,1,2,3,4,5,6,7,8,9)@\\
			\verb@(E I I)* E I?@
			\end{solution}
		\end{parts}	
		
		
\question
	For each of the following finite automata, give an
		equivalent regular expression.
		\begin{parts}
		\part[2] \hspace{0.2in} \\
		\includegraphics[height=1in]{figs/2a.ps}
			\begin{solution}
			\verb@0*1@
			\end{solution}

		\part[2] \hspace{0.2in} \\
		\includegraphics[height=1in]{figs/2b.ps}
			\begin{solution}
			\verb@(0|1)*@
			\end{solution}

		\part[2] \hspace{0.2in} \\
		\includegraphics[height=1in]{figs/2c.ps}
			\begin{solution}
			\verb@((10)+ | (01)+)10@
			\end{solution}

		\end{parts}	

\question[3]
	Let $\sum = {a,b}$.  How many DFA's are there with two
	states and input alphabet $\sum$? (Note: Many of these machines
	may accept the same language.  Count DFA's as different if the
	machines are different,  even if they accept the same
	language.)
			\begin{solution}
			\begin{itemize}
			\item For each of the two states, outgoing arrows may point in one of 4 different configurations
				(0 returns, 1 leaves) (0 and 1 return) (0 and 1 leave) (0 leaves, 1 returns)
				\item There are 2 different possible initial states
				\item There are four possible configurations of final states (accept or not?)
					(No, No) (Yes, No) (No, Yes) (Yes, Yes)
			\end{itemize}
			Therefore there are 4*4*2*4 distinct DFAs = 128
			\end{solution}


\end{questions}		
\end{document}

