\documentclass[11pt]{article}
\usepackage{amsmath,amssymb,amsthm,enumitem,clrscode3e}
\usepackage[margin=1in]{geometry}
\newcommand{\encode}[1]{\langle #1 \rangle}

\title{\bf Assignment 2 \\[2ex]
\rm\normalsize CS 350 \\ Due: October 16, 2019}
\date{}
\author{}

\begin{document}
\maketitle

\begin{center}
    \fbox{\fbox{\parbox{5.5in}{\centering
    Your solutions must be typed (preferably typeset in \LaTeX ) and submitted as a hard-copy at the beginning of class on the day its due. The answers that you provide should clearly demonstrate that you understand the assignment and should provide enough information to clearly explain your solution to a peer.
    When asked to provide an algorithm you need to give well formatted pseudocode and a description of how your code solves the problem.
    }}}
\end{center}

\paragraph{Problem 1}
\subparagraph{(a)} Design a recursive algorithm for computing $2^n$ for any non-negative integer $n$ that is based on the formula: $2^n = 2^{n-1} + 2^{n-1}$.
\subparagraph{(b)} Set up a recurrence relation for the number of additions made by the algorithm and solve it. Show your work.
\subparagraph{(c)} Is it a good algorithm for solving this problem? Describe a better approach.


\paragraph{Problem 2}
The following pseudocode is a modification of the $\proc{Power}$ algorithm we analyzed in lecture.

\begin{codebox}
\Procname{$\proc{ModifiedPower}(x, p)$}
\li \If $p = 0$
    \Then
    \li \Return $1$
    \End
\li \If $p = 1$
    \Then
    \li \Return $x$
    \End
\li \If $p$ is even
    \Then
    \li \Return $\proc{ModifiedPower}(x,\frac p2) \times \proc{ModifiedPower}(x,\frac p2)$
    \End
\li \Return $\proc{ModifiedPower}(x,\frac p2) \times \proc{ModifiedPower}(x,\frac p2) \times x$
\end{codebox}

\subparagraph{(a)} Identify the basic operation of this algorithm and give a recurrence relation describing the number of basic operations performed as a function of $p$.
\subparagraph{(b)} Find a closed form for your recurrence relation.

\end{document}
