\documentclass[11pt]{article}
\usepackage{fullpage}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage[linesnumbered,lined]{algorithm2e}
\usepackage{scrextend}
\makeatletter
\renewcommand{\@algocf@capt@plain}{above}% formerly {bottom}
\makeatother
\usepackage{enumitem}
\setlist[enumerate]{listparindent=\parindent}
\usepackage[colorlinks=true]{hyperref}
\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 1\\\small{Due: Monday, Sep. 18. Upload to Canvas before the beginning of class}}
\author{}
\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{Errors in Inductive Proofs}
\begin{enumerate}
\item \textbf{[2 points]} \href{http://discretetext.oscarlevin.com/dmoi/sec_seq-induction.html#exercises_seq-induction}{DM 2.5.14}
{}
\item \textbf{[6 points]}
Consider bit sequences in which $1$s do not appear consecutively, except in the
rightmost two positions. For instance, $0010100$ and $1000011$ are bit sequences of this
sort, and $0011000$ is not.
What is wrong with the following ``proof'' that there are $2^n$ ``allowed'' sequences of length $n$?
``Proof'' by induction: Let $s_n$ be the number of $n$-bit sequences in which $1$'s do not appear consecutively except in the rightmost two positions. Let $P(n)$ be the
predicate that $s_n = 2^n$. We will prove by induction on $n$ that $P(n)$ is true for all $n\geq 1$.
Base Case: $P(1)$ asserts that $s_1 = 2$. This assertion
is clearly correct: the only possible sequences of length one are $0$ and $1$, and both $0$ and $1$ are allowed.
Inductive Case: Let $k\geq 1$, and assume for induction that $P(k)$ is true. That is, we assume that $s_k=2^k$. We will prove that $P(k+1)$ is true.
For every bit sequence of length $k$, we can
append either $0$ or $1$ at the right end. In the case that we append $0$, we always end up with a valid sequence. In the case that we append $1$, we may create $11$ in the last
two positions, but that's allowed. Therefore,
$$s_{k+1} = 2 s_k = 2 \cdot 2^k = 2^{k+1},$$ and so $P(k+1)$ is true.
Thus, by induction, $P(n)$ is true for all $n\geq 1.$
{}
\end{enumerate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item \textit{Inductive Proofs}
\begin{enumerate}
\item \textbf{[11 points]}
Prove using induction that for $n \geq 0$, $7^n - 2^n$ is divisible by 5. (An integer $m$ is divisible by an integer $r$ if $m=r\cdot g$, where $g$ is some other integer.)
{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item \textbf{[11 points]} Prove using induction that $2^n>n^2$ whenever $n$ is an integer greater than $4.$
{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item \textbf{[11 points]} Prove using induction that Algorithm \ref{algocf:mult} correctly multiplies a non-negative $n$ and an integer $b$. Hint: define $P(n)$ to be the predicate: \texttt{Mult}(n,b) correctly outputs the product of $n$ and $b.$
~\\
\begin{algorithm}[H]
\SetKwInOut{Input}{Input}
\SetKwInOut{Output}{Output}
\Input{Non-negative integer $n$, and integer $b$}
\Output{$n\times b$}
\tcc{Base Case}
\eIf{$n==0$}{
return $0$\\\
}
{ \tcp{Recursive step}
return $b+\texttt{Mult}(n-1,b)$
}
\caption{\texttt{Mult}$(n,b)$}\label{algocf:mult}
\end{algorithm}
{}
\item \textbf{[11 points]} For your programming assignment this week, you have to implement a recursive algorithm. Use an inductive proof to prove that your algorithm works correctly.
{}
\end{enumerate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item How long did you spend on this homework?
\end{enumerate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}