
\documentclass[12pt]{article}

%\setlength{\parindent}{2em}
%\setlength{\parskip}{0ex}
\usepackage[letterpaper,hmargin=1in,vmargin=1in]{geometry}

\newcommand{\comment}[1]{}
\newcommand{\var}[1]{\mbox{\em #1}}
%\pagestyle{empty}

\begin{document}

\bibliographystyle{plain}
\setcounter{page}{1}
%\pagestyle{myheadings}
%\markright{\protect\small DRAFT \hfill\today\hfill page \protect\arabic{page}}

\normalsize

\begin{center}
\LARGE
Homework 3 \\
\normalsize 
\ \\
CS 3343 -- Fall 2006 \hfill assigned September 7, 2006 \\
Tom Bylander, Instructor \hfill due September 15, 2006
\end{center}

Your solutions must be submitted as a document to WebCT.

\begin{enumerate}

\item (20 pts.)
Indicate the order of growth (big theta) of the following sums.
\begin{enumerate}
\item $\displaystyle \sum_{i=1}^n 1/i$
\item $\displaystyle \sum_{i=1}^n \log_2 i$
\item $\displaystyle \sum_{i=1}^n i$
\item $\displaystyle \sum_{i=1}^n i \log_2 i$
\item $\displaystyle \sum_{i=1}^n i^2$
\item $\displaystyle \sum_{i=1}^n i^3$
\item $\displaystyle \sum_{i=1}^n i^4$
\item $\displaystyle \sum_{i=1}^n 2^i$
\item $\displaystyle \sum_{i=1}^n i2^i$
\item $\displaystyle \sum_{i=1}^n i!$
\end{enumerate}


\item (20 pts.) Consider the following algorithm.

\begin{tabbing}
\ \ \ \ \=\ \ \ \ \=\ \ \ \ \=\ \ \ \ \=\kill
{\bf algorithm} $\var{Mystery}(A[0..n-1])$ \+\\
// Input: An array $A$ \\
{\bf for} $i$ $\leftarrow$ 0 {\bf to} $n-1$ {\bf do} \\
\> {\bf for} $j$ $\leftarrow$ $0$ {\bf to} $n-1$ {\bf do} \\
\>\> {\bf if} $A[i] \neq A[j]$ {\bf then} {\bf return} {\bf false} \\
{\bf return} {\bf true}
\end{tabbing}

\begin{enumerate}
\item What does this algorithm compute?
\item What is its basic operation?
\item How many times is the basic operation executed?  (worst-case and
  best-case)
\item What is the efficiency class of this algorithm?  (worst-case and
  best-case)
\item Provide an improvement that improves its worst-case efficiency
  class and indicate the new worst-case efficiency class.
\end{enumerate}

\item (20 pts.)
This is a variation of Exercise 2.4.7.

\begin{enumerate}
\item Provide pseudocode (in the book's style) for two recursive
  algorithms that compute $2^n$ for any integer 
  $n \geq 0$ based on the formula $2^n = 2^{n-1} + 2^{n-1}$.  One algorithm
  should have two recursive calls in the code and the other only one.

\item Draw a tree of recursive calls for each algorithm and use the
  tree to count the number of additions.

\item For both algorithms, set up and solve a recurrence relation for
  the number of additions made by the algorithm.

\item For each algorithm, comment on whether it is a good algorithm
  for solving this problem.
\end{enumerate}

\item (20 pts.)
This is a variation of Exercise 2.5.3.

Find the smallest $n$ for which the $n$th Fibonacci number does not
fit in varables of type {\tt int}, {\tt long}, {\tt float}, and {\tt
double}.  For {\tt float} and {\tt double}, I want to know when the
number cannot be represented exactly, i.e., when you start losing last
digit.

\item (20 pts.)
Do Exercise 2.5.4.  For further exercise, perform all the possible
ways to climb a staircase on one of the stairways between the 3rd and
4th floor of the Science Building.



\end{enumerate}

\end{document}
