\documentclass[11pt]{article}
\usepackage{fullpage}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage[linesnumbered,lined]{algorithm2e}
\usepackage{scrextend}
\usepackage{hyperref}
\usepackage{enumitem}
\usepackage{amsfonts}
\usepackage{float}
\usepackage{amsfonts}
\newcommand{\inlinemaketitle}{{\let\newpage\relax\maketitle}}
\makeatletter
\renewcommand{\@algocf@capt@plain}{above}% formerly {bottom}
\makeatother
\setlist[enumerate]{listparindent=\parindent}
\newcommand{\lxor}{\oplus}
\newcommand{\limplies}{\rightarrow}
\newcommand{\lbicond}{\leftrightarrow}
\newcommand{\universe}{\mathcal{U}}
\newcommand{\implication}{\ensuremath{P \limplies Q}}
\newcommand{\true}{T}
\newcommand{\false}{F}
\usepackage{cleveref}%[nameinlink]
\crefname{lemma}{Lemma}{Lemmas}
\crefname{proposition}{Proposition}{Propositions}
\crefname{definition}{Definition}{Definitions}
\crefname{theorem}{Theorem}{Theorems}
\crefname{conjecture}{Conjecture}{Conjectures}
\crefname{corollary}{Corollary}{Corollaries}
\crefname{section}{Section}{Sections}
\crefname{appendix}{Appendix}{Appendices}
\crefname{figure}{Fig.}{Figs.}
\crefname{equation}{Eq.}{Eqs.}
\crefname{table}{Table}{Tables}
\crefname{algocf}{Algorithm}{Algorithms}
\title{CS200 - Problem Set 8\\\small{Due: Monday, Nov. 13 to submission server before class}}
\author{}
\date{}
\parindent=.25in
\begin{document}
\maketitle
\vspace{-2cm}
Please read the sections of the syllabus on problem sets and honor code before starting this homework.
\begin{enumerate}
\item \textbf{[11 points]} Prove $x^2-5x+100=\Theta(x^2).$
{}
\item \textbf{[6 points]} Suppose I have an algorithm whose runtime on inputs of size $1$, $2$, $3,$ $4,$ and $5$ are
\begin{center}
\begin{tabular}[h]{|l|c|c|c|c|c|}
\hline
Input Size & 1& 2& 3 &4 & 5\\\hline
Runtime & 1 & 1 & 1 & 1 & 1\\
\hline
\end{tabular}
\end{center}
\noindent Explain how this algorithm could have an asymptotic runtime of $\Omega(2^n).$
{}
\item In the following, you may assume that the graph $(V,E)$ is undirected and does not have self loops or multi-edges. Let $deg(v)$ be the degree of a vertex $v$. Rewrite each predicate using math.
\begin{enumerate}
\item \textbf{[3 points]} $D(v,u,(V,E))\equiv$ In the graph $(V,E)$ there is a path of length 2 from vertex $v$ to vertex $u$.
\item \textbf{[3 points]} $R(v,(V,E))\equiv$ $v$ is the vertex with the smallest degree in the graph $(V,E)$
\item \textbf{[3 points]} $W(V,E)\equiv$ There is a vertex in the graph $(V,E)$ that is not connected to any other vertices.
\item \textbf{[3 points]} $M(V,E)\equiv$ There is a vertex in the graph $(V,E)$ that is connected to all other vertices.
\item \textbf{[3 points]} $T(V,E)\equiv$ All vertices in the graph $(V,E)$ have the same degree.
\item \textbf{[3 points]} $K(V,E)\equiv$ All vertices in the graph $(V,E)$ have even degree.
\item \textbf{[3 points]} $R(V,E)\equiv$ The graph $(V,E)$ is bipartite, which means there are two sets of vertices $A$, $B$ that are not empty, and such that there are not any edges between two vertices in $A$, and there are not any edges between two vertices in $B$.
\item \textbf{[3 points]} $L(V,E)\equiv$ The graph $(V,E)$ is bipartite with sets $A$ and $B$, and all vertices in $A$ are connected to all vertices in $B.$
\end{enumerate}
{}
\item Graph Search. In this problem we will use the graph described by the following adjacency list:
$\textbf{A}:$
\begin{tabular}{| c| c| }
\hline
vertex & adjacency list\\
\hline
$s$ & $u$, $y$\\
$u$ & $v$, $z$, $s$ \\
$y$ & $s$, $z$ \\
$v$ & $w$, $a$, $u$\\
$z$ & $w$, $u$, $y$\\
$a$ & $v$, $t$\\
$w$ & $v$, $t$, $z$\\
$t$ & $a$, $w$\\
\hline
\end{tabular}
We will also use the algorithm \texttt{DepthFirstSearch}, which is a version of the Graph Search algorithm we saw in class. It's pseudocode is:
\begin{figure}[H]
\centering
\begin{minipage}{.7\linewidth}
\begin{algorithm}[H]
\SetKwInOut{Input}{Input}
\SetKwInOut{Output}{Output}
\Input{Adjacency list $A$ for a graph $G=(V,E)$, an array $X$ of length $|V|$ such that $X[v]=1$ if $v$ has been explored and $0$ otherwise, a starting vertex $s$, a goal vertex $f$}
\Output{String ``$f$ found!'' or ``$f$ not found'' depending on whether $f$ can be found from $s$.}
\eIf{$s==f$}{
Return ``$f$ found!''\;
}
{
$X[s]=1$\;
$d=A[s].length$\;
\For{$k=1$ \KwTo $d$}{
\If{$X[A[s,k]]==0$}{
\texttt{DepthFirstSearch($A,X,A[s,k],f$)}\;
}
}
}
Return ``$f$ not found''
\caption{\texttt{DepthFirstSearch}$(A,X,s,f)$}\label{alg:DFS}
\end{algorithm}
\end{minipage}
\end{figure}
\begin{enumerate}
\item \textbf{[6 points]} Please draw the graph the adjacency list corresponds to.
\item \textbf{[6 points]} Suppose you start at $s$, and want to find $t$. In what order are vertices explored if you use \texttt{DepthFirstSearch}($A,X,s,t$)? (Where $X$ is initially set to all zeros)
\item \textbf{[6 points]} Suppose you start at $s$, and want to find $y$. In what order are vertices explored if you use \texttt{DepthFirstSearch}($A,X,s,y$)? (Where $X$ is initially set to all zeros)?
\item \textbf{[6 points]} Qualitatively describe how \texttt{DepthFirstSearch} explores the graph.
\item \textbf{[6 points]} In our generic Graph Search algorithm from class on Monday, we did not decide how to choose the next explored edge, in the case that there were multiple edges we could explore. How does \texttt{DepthFirstSearch} choose which edge to explore next?
\end{enumerate}
{}
\item \textbf{[6 points]} Suppose you have a weighted coin such that the probability of heads is $0.3$ and the probability of tails is $0.7$. What is the probability of getting at least 3 heads, if you flip the coin $10$ timess?
{}
\item How long did you spend on this homework?
\end{enumerate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}