\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}
\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 8}
\author{}
\date{}
\parindent=.25in
\begin{document}
\maketitle
\vspace{-2cm}
\begin{enumerate}
\item When discussing the ethical and societal consequences of algorithms, we have been doing it in a fairly unsystematic way. Most of us are not experts in philosophy or ethics or even know that much about the application domains for these algorithms (e.g. air traffic control). (Although one thing I've been pleasantly surprised with is that, despite our non-expertness, simply having a large group of people brainstorm seems to bring a lot of issues to light!)
People who are experts in philosophy and ethics are considering these types of questions, and have come up with various frameworks for helping algorithm developers assess their algorithms. We will learn about and consider a few of these frameworks.
Consider the following framework based on the (thanks to COVID now unfortunately relatively familiar) pharmaceutical drug testing phases:
\includegraphics[scale=.5]{Phases.png}
This was taken from the article \href{https://hdsr.mitpress.mit.edu/pub/56lnenzj/release/1}{Should We Trust Algorithms?} by David Spiegelhalter. (You don't need to read the rest of the article, but I encourage you to if you are interested!)
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 detect problematic behavior in these algorithms? What are the challenges of implementing such an approach? Who should regulate this process if implemented? Do you like this framework? When do you think such an approach should be used? 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 without
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, remove $g$ from $T$ (i.e. set $T$ to equal $T-\{g\}$). Repeat this process, removing the guessed index from $T$ each time you guess incorrectly, so the set of indices that you are guessing from gets smaller and smaller over time, until you sample an index $g$ such that $A[g]=t$. (Replacement refers to whether the guessed index is placed back (``replaced'') into the guessing set $T$ or removed after it is guessed.)
\begin{enumerate}
\item What is the sample space $S$ for sampling without replacement for an array of size $3$, if the item you are looking for is at position $1$? (Please list all elements of the sample space, do not describe in words.)
\item Let $R:S\rightarrow \mathbb{R}$ be the random variable such that, for an element $\sigma$ of the sample space, $R(\sigma)$ is the number of rounds (guesses) that occur in the algorithm when the sequence of random outcomes is $\sigma$. What is the value of $R$ for each element of $S$ that you listed in the previous part?
\item In the case of the length $3$ array, consider the indicator random variables $X_i:S\rightarrow\{0,1\}$ where
\begin{align}
X_i(\sigma)=
\begin{cases}
1&\textrm{ if }\sigma\textrm{ has at least }i\textrm{ rounds}\\
0&\textrm{ if }\sigma\textrm{ has less than }i\textrm{ rounds}.
\end{cases}
\end{align}
We can write $R$ as a weighted sum of these indicator random variables:
\begin{align}\label{eq:Rweight}
R(\sigma)=\sum_{i=1}^3X_i(\sigma).
\end{align}
Choose an element $\sigma\in S$ from part (a), calculate $X_i(\sigma)$ for each $i$, and show that indeed, $R(\sigma)=\sum_{i=1}^3X_i(\sigma)$ for that particular element $\sigma$.
\item Now consider search without replacement with a length-$n$ array. Please describe the sample space as concisely but as descriptively as possible using English. (Your description should be more precise than, e.g. ``The set of possible sequences of random outcomes that occur over the course of the algorithm.'')
\item Now consider a length-$n$ array, and, as in the length-3 example, let $R:S\rightarrow \mathbb{R}$ be the number of rounds that occur for a given element of the sample space, and let
\begin{align}
X_i(\sigma)=
\begin{cases}
1&\textrm{ if }\sigma\textrm{ has at least }i\textrm{ rounds}\\
0&\textrm{ if }\sigma\textrm{ has less than }i\textrm{ rounds}.
\end{cases}
\end{align}
Using linearity of expectation and the special properties of indicator random variables that we've seen in our analysis of QuickSort, determine $\mathbb{E}[R]$ when we have a length-$n$ array. (Help on determining the probability of the events associated with indicator random variables is on the hints.)
\item Please comment on the average-case vs best-case vs worst-case runtime of search without replacement.
\end{enumerate}
{}
{}
\item You run a plant that produces sheets of aluminum alloy, and then you cut
them to size for customers. Your machine produces rectangular sheets of dimension $Q\times
R$, and you can cut any sheet into two smaller sheets by making a vertical or
horizontal cut at an integer location. So for example, if you have a $2\times 4$ sized piece, you have the following options that you could produce from a single cut:
\begin{itemize}
\item Two $1\times 4$ pieces (from a horizontal cut at position 1).
\item Two $2\times 2$ pieces (from a vertical cut at position 2).
\item A $1\times 2$ and a $2\times 3$ piece (form a vertical cut at position 1).
\end{itemize}
Say you decide to make the cut that produces a $1\times 2$ and a $2\times 3$ piece. You could then subsequently cut the $1\times 2$ piece into two $1\times 1$ pieces, and the $2\times 3$ piece into a $2\times 1$ piece and a $2\times 2$ piece, and so on. Or you could stop cutting and sell a piece that you've created.
You can also rotate pieces (so a $2\times 3$ piece is the same as a $3\times 2$ piece).
Suppose you produce $n$ different sized products, where product $i$ has dimensions $x_i\times y_i$, and you can sell product $i$ for $v_i$ dollars.
(For example, perhaps product $1$ is a $2\times 2$ piece that you can sell for \$2, and product $2$ is a $3\times 5$ piece that you can sell for \$3 dollars.)
You can sell multiple copies of the $i$th
product if you can produce multiple pieces of that size from your original sheet. Assume $Q$, $R$,
$x_i$, $y_i$, and $v_i$ for $i\in\{1,2,\dots,n\}$ are positive integers. You will design an algorithm
that figures out your maximum profit among any possible sequence of horizontal/vertical cuts.
\begin{enumerate}
\item Please provide pseudocode for a dynamic
programming algorithm that outputs your maximum profit. (Note: your code doesn't have to output how you should actually divide the piece, just the profit.) The input to your algorithm should be $(Q,R,x,y,z)$ where $Q$ and $R$ are the size of the piece, array $x$ contains the values $x_i$, array $y$ contains the values $y_i$, and array $v$ contains the values $v_i$.
\item Explain why your algorithm is correct. (You don't need to write a full proof, but you should describe the logic behind the recurrences that you developed to create your algorithm and explain how your algorithm checks the appropriate cases.)
\item What is the runtime of your algorithm in terms of $Q$, $R$, and $n$?
\item Explain briefly how you would modify your algorithm to tell you whether you should divide the current sheet, and if so, where you should make the cut.
\end{enumerate}
{}
{}
\item
Here are some problem definitions:
\begin{itemize}
\item \textsf{DOUBLE-3-SAT}: Given a 3-CNF formula involving the variables $x_1,x_2,\dots,x_n$ and their negations, with at most $m$ clauses, are there at least two different satisfying assignments? For example, $(x_1 \vee \neg x_1 \vee \neg x_2) \wedge (x_2 \vee x_3) \wedge (\neg x_3)$ has two unique valid assignments, $x_1 = 1, x_2 = 1, x_3 = 0$ and $x_1 = 0, x_2 = 1, x_3 = 0$.
\item $k$-\textsf{INDSET}: Given an undirected, unweighted graph $G=(V,E)$, is there a set $V'\subseteq V$ such that $|V'|\geq k$, and for all $v,u\in V'$, there is no edge $\{u,v\}\in E$?
\item $k$-\textsf{CLIQUE}: Given an undirected, unweighted graph $G=(V,E)$, is there a set $V'\subseteq V$ such that $|V'|\geq k$, and for all $v,u\in V'$, there is an edge $\{u,v\}\in E$?
\end{itemize}
\begin{enumerate}
\item Prove \textsf{DOUBLE-3-SAT} is in \textsf{NP}.
\item Prove $k$-\textsf{INDSET} is in \textsf{NP}.
\item Prove $k$-\textsf{CLIQUE} is in \textsf{NP}.
\end{enumerate}
{}
{}
\end{enumerate}
\end{document}