\documentclass[12pt]{article}
\usepackage{fullpage}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage[linesnumbered,lined]{algorithm2e}
\usepackage{scrextend}
\usepackage{hyperref}
\usepackage{enumitem}
\usepackage{amsfonts}
\usepackage{float}
\usepackage{amsfonts}
\usepackage{tikz}
\newlist{steps}{enumerate}{1}
\setlist[steps, 1]{label = Step \arabic*:}
\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{CS302 - Problem Set 9}
\author{}
\date{}
\parindent=.25in
\begin{document}
\maketitle
\vspace{-2cm}
\begin{enumerate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item Continuing our investigation of frameworks for thinking about the ethical and societal consequences of algorithms, please read the Fairness, Accountability, and Transparency in Machine Learning groups' \href{https://www.fatml.org/resources/principles-for-accountable-algorithms}{Principles for Accountable Algorithms and a Social Impact Statement for Algorithms}.
Think about some of the algorithms that we have considered in this class: scheduling algorithms for optimizing grades, Google, robot optimization, flight path optimization, cell tower optimization, Huffman's coding. Do you think this approach would help curb problematic aspect of applying these algorithms? When do you think such an approach should be used? What are the challenges of implementing such an approach? Do you like this framework? What are strengths or weaknesses of this framework relative to the previous (``Phases'') approach? Write a brief response to at least a few of these questions - we will discuss in class after seeing a couple of ideas for ethical frameworks.
\item Suppose you are searching an array $A$ of length $n$ for an element with value $t$. You may assume $A$ has no repeated elements and that $t$ is in $A$.
The strategy \textit{sampling with
replacement} works as follows: Let $T=\{1,2,\dots,n\}$. Choose (``sample'') an element $g\in T$ at random, and check if
$A[g]=t$. If it is, return $g$. If it is not, guess a new element at random from $T=\{1,2,\dots,n\}$. Repeat this process, until $g$ such that $A[g]=t$ is found. What is the average runtime of this algorithm?
\textbf{Challenge:} suppose instead you don't know whether $t$ is in $A$ or not.
If $t$ is not in $A$, what is the average runtime before you randomly sample all indices \textit{sampling with
replacement} and therefore realize that $t$ is not in $A$?
{}
{}
\item
\begin{enumerate}
\item Write pseudocode to output the shortest path using the array produced in the first part of the Bellman-Ford algorithm.
\begin{figure}[H]
\centering
\begin{minipage}{.9\linewidth}
\begin{algorithm}[H]
\SetKwInOut{Input}{Input}
\SetKwInOut{Output}{Output}
\Input{Vertices $s,t$ in a graph $G=(V, E)$ with no negative weight cycles, $|V|=n$, where $G$ is given via an array of weights $w$ where $w[u,v]$ gives the weight of edge $(u,v)$, ($w[u,v]=\infty$ if there is no edge from $u$ to $v$), and an array $A$ where the first dimension of $A$ is indexed by the elements of $V$, and the second dimension is labeled by indices from $0$ to $|V|-1$. Then $A[v,i]$ contains the length of the shortest path from $s$ to $v$ that uses at most $i$ edges.}
\Output{The shortest path from $s$ to $t$.}
\lIf{$A[t,n-1]=\infty$}{
return ``No Path''
}
\tcp{Your pseudocode here!}
\caption{\texttt{ShortestPath}$(s,t,w,A)$}\label{algocf:BellmanFord}
\end{algorithm}
\end{minipage}
\end{figure}
\item What is the runtime of your pseudocode if you are given the array $w$ as described above?
\item If you are instead given $G$ as a reverse adjacency list, what would be the runtime of this algorithm, and why?
\end{enumerate}
{}
\item
\begin{enumerate}
\item In the version of Bellman-Ford we looked at in class, we assume that there are no negative cycles in the graph. Describe briefly in words how you could use the Bellman-Ford algorithm to detect whether there is a negative cycle or not (that is reachable via a path from $s$). Then modify the algorithm from class to do this detection. Assume the $G$ is given as an array $w$.
\item Next create an algorithm that, given a graph that contains a negative cycle reachable from $s$, will return the set of edges on the negative cycle. Assume the $G$ is given as an array $w$. (As mentioned in class, this algorithm is used in currency arbitrage.)
\end{enumerate}
{}
{}
\item (Optional: If you would like additional practice with proving problems are in NP.) The problem \textsf{MWIS-Decision} is as follows. Given a graph $G=(V,E)$, a weighting function $w:V\rightarrow \mathbb{R}$ on the vertices of $G$, and $D\in\mathbb{R}$, is there an independent set on $G$ with weight at least $D?$ Prove \textsf{MWIS-Decision}$\in \textsf{NP}$.
{}
\end{enumerate}
\end{document}