\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 10\\\small{Due: Monday, May. 7 to Canvas}}
\author{}
\date{}
\parindent=.25in
\begin{document}
\maketitle
\vspace{-2cm}
\begin{enumerate}
\item Let $G$ be the following graph, and let $A_G$ be an adjacency list representation of the $G$ with the adjacency list for each vertex in alphabetical order.
\includegraphics[scale=.9]{graph.pdf}
Consider the following slight variation to breadth-first-search:
\begin{figure}[H]
\centering
\begin{minipage}{.8\linewidth}
\begin{algorithm}[H]
\SetKwInOut{Input}{Input}
\SetKwInOut{Output}{Output}
\Input{Adjacency list $A$ for a graph $(V,E)$ and vertex $s$}
\Output{An integer array $L$ of length $|V|$.}
\tcp{Initialize array of explored vertices and array $L$}
$X[v]=0$ $ \forall v\in V$\;
$L[v]=\infty $ $\forall v\in V$\;
$X[s]=1$\;
$L[s]=0$\;
\tcp{Initialize Queue $A$}
$A=\{\}$\;
$A.add(s)$\;
\While{$A$ is not empty}{
$v=A.pop$\;
\For{each edge $\{v,w\}$}{
\If{$X[w]==0$}{
$X[w]=1$\;
$A.add(w)$\;
$L[w]=L[v]+1$\;
}
}
}
return $L$
\caption{\texttt{BFSish}$(A,s)$}\label{alg:DFS}
\end{algorithm}
\end{minipage}
\end{figure}
\begin{enumerate}
\item \textbf{[6 points]} In what order does \texttt{BFSish}$(A_G,a)$ explore the nodes of the graph $G$? (Remember lists of the adjacency list representation are in alphabetical order, so the for loop in line 9 will look at vertices in alphabetical order.)
\item \textbf{[6 points]} What are the values in the array $L$ that is returned when \texttt{BFSish}$(A_G,a)$ is implemented?
\item \textbf{[3 points]} Considering your answer to part b, what does it seem like the algorithm is doing? What is the meaning of $L$? Think about the relationship between $a$, $b$, and $L[b]$.
\end{enumerate}
{}
\item Consider rolling $5$ dice. Let $X_{i,j}$ be an indicator random variable that takes value $1$ if the $i$th di has outcome $j$ (and takes value $0$ otherwise).
\begin{enumerate}
\item \textbf{[3 points]} What is the sample space? What is its size?
\item \textbf{[3 points]} Let $X$ be the random variable that is the sum of all of the values shown on the dice. If the outcome of the rolls is $s=(4,2,4,5,1)$, what is $X(s)$? What is $X_{3,4}(s)$? What is $X_{4,3}(s)$?
\item \textbf{[3 points]} Write $X$ in terms of a \textit{weighted} sum of the variables $X_{i,j}$.
\item \textbf{[3 points]} What is $\mathbb{E}[X_{i,j}]$?
\item \textbf{[3 points]} Use linearity of expectation to determine the average value of the sum of all values shown on the dice.
\end{enumerate}
{}
\item Suppose a group of $n$ people each order a different flavor of ice cream at an ice cream shop. Suppose the server didn't keep track of who ordered which flavor, and just handed the ice cream out randomly.
\begin{enumerate}
\item \textbf{3 points} Let $X$ a random variable that is the number of people who got handed the correct flavor. Let $X_i$ be the indicator random variable that takes value $1$ if person $i$ gets the correct flavor (and $0$ otherwise.) Write $X$ in terms of a sum of the $X_i$.
\item \textbf{6 points} Use linearity of expectation to determine the average number of people who get the correct flavor.
\end{enumerate}
{}
\item \textbf{[6 points]} Suppose you have an algorithm that has a time complexty $T(r,l)$ given by the recurrence relation:
\begin{align}
T(1,l)=O(l)\nonumber\\
T(r,l)=2T(r/2,l)+O(rl)
\end{align}
This recurrence relation is technically not one of the cases that the master method covers. However, you can use the same strategy as the master method to get an expression for $T(r,l)$ in terms of $r$ and $l.$ Please use this strategy to find a big-O bound on $T(r,l).$
{}
\item
Suppose you have devised three different divide and conquer algorithms to solve the same problem:
\begin{itemize}
\item Algorithm I: Divides the problem into three subproblems that are each a quarter of the size of the original problem. It uses linear time to combine the solutions to the subproblems.
\item Algorithm II: Divides the problem into 2 subproblems that are each 2/3 the size of the original problem. It uses constant time to combine the solutions to the subproblems.
\item Algorithm III: Divides the problem into 9 subproblems that are each a third the size of the original problem. It uses quadratic time to combine the solutions to the subproblems.
\end{itemize}
\begin{enumerate}
\item \textbf{[6 points]} For each algorithm, give the asymptotic complexity using big-O notation.
\item \textbf{[6 points]} State which of the algorithms you would use to solve an instance of this problem.
\end{enumerate}
{}
\item \textbf{[This problem will be part of an ``optional'' final problem set.]} \textbf{[6 points]} Let $A=\mathbb{N}$, and $B=\{1,2\}\times \mathbb{N}$. Show $|A|=|B|.$
{}
\item How long did you spend on this homework?
\end{enumerate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}