\documentclass[11pt]{article}
\usepackage{fullpage}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage[linesnumbered,lined]{algorithm2e}
\usepackage{scrextend}
\makeatletter
\renewcommand{\@algocf@capt@plain}{above}% formerly {bottom}
\makeatother
\usepackage{enumitem}
\setlist[enumerate]{listparindent=\parindent}
\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 1\\\small{Due: Monday, Sep. 18. Must be uploaded to Canvas before the beginning of class.}}
\date{}
\parindent=.25in
\parskip 7.2pt
\begin{document}
\maketitle
Please read the sections of the syllabus on problem sets and honor code before starting this homework.
\begin{enumerate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item \textit{Big-O Review}
For each of the following, decide whether the statement is true or false, and justify your answer. Recall that $f(x)=O(g(x))$
if there are constants $C$ and $k$ such that
$|f(x)|\leq C|g(x)|$ whenever $x>k$. You may assume $n$ is a positive integer.
\begin{enumerate}
\item \textbf{[3 points]} $3n\log_{10}(n)+2n+100=O(n\log_2(n))$
\item \textbf{[3 points]} $2^{2n}=O(2^n)$
\item \textbf{[3 points]} $\log(n!)=O(n\log n)$ (Hint: what is the relationship between $n!$ and $n^n$?)
\end{enumerate}
{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item \textit{More Big-O Review} \textbf{[6 points]}
Consider the following table, which contains the runtime in milliseconds for three different
algorithms with five different input sizes ($10$, $20$, $50$, $1000$ , $2000$). For each algorithm, give a big-O
bound on the runtime.
\begin{center}
\begin{tabular}[h]{|l|c|c|c|c|c|}
\hline
& 10& 20& 50& 1000 & 2000\\\hline
Algorithm 1 & 50 & 110 & 900 & 1990& 3000\\
Algorithm 2 & 1 & 2 & 3 & 4 &5 \\
Algorithm 3 & 10 & 10 & 10 & 10&10\\
\hline
\end{tabular}
\end{center}
{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item \textit{Real-World Multiplication} \textbf{[3 pts]} I pulled the following text from python source code:
\begin{align}
&\textrm{/* For long multiplication, use the O(N**2) school algorithm unless}\nonumber\\
&\textrm{* both operands contain more than KARATSUBA\textunderscore CUTOFF digits (this}\nonumber\\
&\textrm{* being an internal Python long digit, in base PyLong\textunderscore BASE).}\nonumber\\
&\textrm{*/}\nonumber\\
&\textrm{\#define KARATSUBA\textunderscore CUTOFF 70}
\end{align}
Explain what choice is being made here, and why.
{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item \textit{Inductive Proofs Review}
\begin{enumerate}
\item \textbf{[11 points]} Use induction to prove that for all $n \geq 0$:
\begin{align}
1 + r + r^{2} + r^{3} + \ldots + r^{n} = \frac{r^{n+1} - 1}{r - 1}
\end{align}
where $r$ is any number not equal to 1. Make sure your inductive proof
clearly denotes the base case and the inductive step.
\item \textbf{[3 points]} Where in your proof did you use the fact that $r \neq 1$?
\item \textbf{[2 points]} What does the sum evaluate to when $r = 1$?
\end{enumerate}
{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item Let \texttt{SelfReference} be an algorithm that takes as input a sorted (in increasing order) array $A$ of $n$ distinct integers, and returns an index $i$ such that $A[i]=i$, or returns $0$ otherwise. (Assume the indices of $A$ start at $1$ and go to $n$.)
\begin{enumerate}
\item \textbf{[9 points]} Write psuedocode for a recursive version of \texttt{SelfReference} that is as fast as possible. (Your algorithm can take additional inputs if you find it helpful.)
\item \textbf{[11 points]} Prove your algorithm is correct.
\item \textbf{[3 points]} What is the asymptotic runtime of your algorithm? Take 3 bonus points if your algorithm is as fast or faster than mine.
\end{enumerate}
{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item Approximately how long did you spend on this assignment (round to the nearest hour)?
\end{enumerate}
\end{document}