\documentclass[11pt]{article}
\usepackage{fullpage}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage[linesnumbered,lined]{algorithm2e}
\usepackage{scrextend}
\usepackage{hyperref}
\usepackage{enumitem}
\usepackage{amsfonts}
\makeatletter
\renewcommand{\@algocf@capt@plain}{above}% formerly {bottom}
\makeatother
\usepackage{enumitem}
\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}
\newcommand{\Z}{\mathbb{Z}}
\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 2\\\small{Due: Monday, Feb. 26 to Canvas before class}}
\author{}
\date{}
\parindent=.25in
\parskip 7.2pt
\begin{document}
\maketitle
\vspace{-1cm}
Please read the sections of the syllabus on problem sets and honor code before starting this homework.
\begin{enumerate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item \textit{Don't forget induction!} \textbf{[11 points]}
Prove that Algorithm \ref{algocf:max} correctly searches an array of integers for a specific integer. Hint: let $P(n)$ be the predicate: \texttt{Search} works correctly on an input array of size $n$. Hint: take a look at the previous week's solution to remind your self about the general strategy for algorithms.
~\\~\\
\begin{algorithm}[H]
\SetKwInOut{Input}{Input}
\SetKwInOut{Output}{Output}
\Input{Integer $s$, and an array of integers $A$}
\Output{Returns $i$ such that $A[i]=s$, or $-1$, if $s$ is not in the array. (The first element of $A$ is at position $1$.)}
$n = $ length of $A$\;
\tcc{Base Case}
\eIf{$n==1$}{
\eIf{$A[1]==s$}{
return $n$\;
}
{
return $-1$\;
}
\tcc{Recursive case:}
}
{
\eIf{$A[n]==s$}{
return $n$\;
}
{
return \texttt{Search}$(s,A[1:n-1])$\;
}
}
\caption{\texttt{Search}$(s,A)$}\label{algocf:max}
\end{algorithm}
{}
\item \textit{Set Builder to Roster Notation}
\textbf{[2 point each]}
The following sets are described in set builder notation.
Describe each of them in roster notation, instead.
The following symbols are used:
$\mathbb{Z}$ denotes the set of integers; $\mathbb{R}$ denotes the set of real numbers;
$\mathbb{N}$ denotes the set of natural numbers, i.e., $\mathbb{N} = \{1, 2, \dots \}$.
\begin{enumerate}
\item
$\{r :r \in \mathbb{R} \mbox{ and } r = r^2 \}$
\item
$\{n :n \in \mathbb{N} \mbox{ and } n > n^2 \}$
\item
$\{x :\mbox{$x$ is a letter in the word \emph{accommodate}}\}$
\item
$\{z^2 :z \in \mathbb{Z} \mbox{ and } 6 < z^3 < 160 \}$.
\item
$\{S \subseteq \{2, 4, 6, 8\} :S \cap \{2,4\} \neq \emptyset \mbox{ and $|S|$ is even} \}$
\end{enumerate}
{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item \textit{Set builder notation} \textbf{[3 points each]} Write each of the following sets using set-builder notation:
\begin{enumerate}
\item $A=\{\dots,1/8,1/6,1/4,1/2,2,4,6,8\dots\}$
\item $B=\{1,2,4,8,16,32,\dots\}$
\item $A\cap B$
\item Express the set of all sets of 2 integers such that the two numbers in the set are non-zero, have opposite signs,
and the magnitude of one of them is the square of the magnitude of the other.
\end{enumerate}
{}
\item \textit{Universal Set} \textbf{[2 points]}
Let $U$, the universal set, be the set of even integers from 2 to 12 inclusive, and
let $A = \{4, 6, 7, 9\}$, $B = \{2, 3, 4, 5, 7\}$. What is $\overline{A - B}$?
{}
\item \textit{Set Operations} \textbf{[2 points each]}
%(3 points)
Simplify each of the following expressions, where $A$ is an arbitrary set, $\emptyset$ is the empty set, and $U$ is the universal set. Hint: each answer to (a)-(h) is one of $A$, $U$, or $\emptyset$.
Just write down the answer: no proof needed, no steps need be shown.
\begin{enumerate}
\item
$A \cap U$
\item
$A \cap \emptyset$
\item
$A \cup U$
\item
$A \cup \emptyset$
\item
$A \cup A$
\item
$A \cap A$
\item
$A \cup \overline{A}$
\item
$A \cap \overline{A}$
\end{enumerate}
{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item \textit{Statements} \textbf{[3 points each]} For each of the following sentences, decide whether it is a statement, predicate, or neither, and explain why
\begin{enumerate}
\item Call me Ishmael.
\item The universe is supported on the back of a giant tortoise.
\item $x$ is a multiple of $7.$
\item The next sentence is true.
\item The preceding sentence is false.
\item The set $\mathbb{Z}$ contains an infinite number of elements.
\end{enumerate}
{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item\textit{Statements} \textbf{[2 point each]}
~\\
\textbf{This problem has been postponed until next week's problem set!! If you've already done it, that is OK - but please include your solution for next week, too.}\\~\\
% (4 points)
Simplify each of the following expressions, where $p$ denotes a statement, and $T$ and $F$ are the
Boolean constants {\em true} and {\em false}. Hint: each answer is one of $p$, $T$, or $F$. No proof needed, no steps need be shown.
\begin{enumerate}
\item
$T \wedge p$
\item
$F \wedge p$
\item
$T \vee p$
\item
$F \vee p$
\item
$p \vee p$
\item
$p \wedge p$
\item
$p \vee \neg p$
\end{enumerate}
{}
\item How long did you spend on this homework?
\end{enumerate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}