\documentclass[11pt]{article}
\usepackage{amsmath,amssymb,amsthm,tabu,enumerate,tikz}
\usetikzlibrary{automata,positioning}
\usepackage[margin=1in]{geometry}
\newcommand{\encode}[1]{\langle #1 \rangle}

\title{\vspace{-3ex}\bf Exploring NFAs \\[2ex]
\rm\normalsize CS 311, Fall 2015}
\date{}
\author{}

\begin{document}
\maketitle

\paragraph{Exercise 1} Consider the following NFA $N$, and the string $s=011101110$:

\begin{center}
\begin{tikzpicture}[%
       >=stealth,
       node distance=4cm,
       on grid,
       auto
    ]
    \node[initial,initial text=,state] (0) {$q_0$};
    \node[state] (1) [right=3cm of 0] {$q_1$};
    \node[state] (2) [below=2cm of 0] {$q_2$};
    \node[state] (3) [below right=2cm of 2] {$q_3$};
    \node[state] (4) [right=2cm of 3] {$q_4$};
    \node[state,accepting] (5) [right=2cm of 4] {$q_5$};

    \path[->] (0) edge[loop above] node {0} (0);
    \path[->] (0) edge[bend left] node {1} (1);
    \path[->] (1) edge[bend left] node {0} (0);
    \path[->] (1) edge[bend left, below] node {1} (2);
    \path[->] (2) edge[left] node {0} (0);
    \path[->] (2) edge[loop left] node {1} (2);
    \path[->] (2) edge[below] node {$\varepsilon$} (3);
    \path[->] (3) edge[above] node {1} (4);
    \path[->] (4) edge[above] node {0} (5);
    \path[->] (5) edge[loop above] node {0,1} (5);

\end{tikzpicture}
\end{center}

\begin{enumerate}[a)]
    \item Give two legal sequences of states the machine could go through that end in an accepting state. \\\\\\\\\\\\
    \item Give one legal sequence of states the machine could go through that doesn't end in an accepting state. \\\\\\\\\\\\
    \item Does the NFA $N$ accept $s$? \\\\\\
    \item What language is recognized by $N$?
\end{enumerate}

\newpage

\paragraph{Exercise 2} Draw a state machine for the NFA that recognizes each of the following 
    languages and has the specified number of states.

\begin{enumerate}[a)]
    \item $\{w  \;|\; w \mbox{ ends with } 00 \}$ with three states.
    \vspace{40ex}
    \item $\{w \;|\; w \mbox{ contains the substring } 0101 \}$ with five states.
    \vspace{40ex}
    \item The language $\{0\}$ with two states.
\end{enumerate}

\end{document}
