% Template LaTeX source file for homework problem solutions. % Alan T. Sherman (9/9/98) % Running LaTeX % % Name this file FOO.tex % latex FOO % latex FOO % (You have to run latex twice to get the cross references correct. % Running latex creates a file FOO.dvi % You can view dvi files with the program xdvi ) % xdvi FOO.dvi & % % lpr -d FOO.dvi % (To print the dvi file. Be sure to use the "-d" print option, % and be sure your printer can handle dvi files (not all printers can). % Do NOT print with "lpr FOO.dvi", which will print tens of pages % of unreadable dvi source code. Printing a postscript (ps) file % is usually more reliable, as explained below.) % % dvips FOO.dvi % (To create a postscript file named FOO.ps % which you can view with the program ghostview ) % ghostview FOO.ps & % lpr FOO.ps % (To print the ps file.) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \documentstyle[12pt]{article} % Set the margins % \setlength{\textheight}{8.5in} \setlength{\headheight}{.25in} \setlength{\headsep}{.25in} \setlength{\topmargin}{0in} \setlength{\textwidth}{6.5in} \setlength{\oddsidemargin}{0in} \setlength{\evensidemargin}{0in} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Macros % Math Macros. It would be better to use the AMS LaTeX package, % including the Bbb fonts, but I'm showing how to get by with the most % primitive version of LaTeX. I follow the naming convention to begin % user-defined macro and variable names with the prefix "my" to make it % easier to distiguish user-defined macros from LaTeX commands. % \newcommand{\myN}{\hbox{N\hspace*{-.9em}I\hspace*{.4em}}} \newcommand{\myZ}{\hbox{Z}^+} \newcommand{\myR}{\hbox{R}} \newcommand{\myfunction}[3] {${#1} : {#2} \rightarrow {#3}$ } \newcommand{\myzrfunction}[1] {\myfunction{#1}{{\myZ}}{{\myR}}} % Formating Macros % \newcommand{\myheader}[4] {\vspace*{-0.5in} \noindent {#1} \hfill {#3} \noindent {#2} \hfill {#4} \noindent \rule[8pt]{\textwidth}{1pt} \vspace{1ex} } % end \myheader \newcommand{\myalgsheader}[0] {\myheader{UMBC, Department of Computer Science and Electrical Engineering} {CMSC-441 Algorithms}{Fall 1998}{Section 0101}} % Running head (goes at top of each page, beginning with page 2. % Must precede by \pagestyle{myheadings}. \newcommand{\myrunninghead}[2] {\markright{{\it {#1}, {#2}}}} \newcommand{\myrunningalgshead}[2] {\myrunninghead{CMSC-441 Algorithms}{{#1}}} \newcommand{\myrunninghwhead}[2] {\myrunningalgshead{Solution to HW {#1}, Problem {#2}}} \newcommand{\mytitle}[1] {\begin{center} {\large {\bf {#1}}} \end{center}} \newcommand{\myhwtitle}[3] {\begin{center} {\large {\bf Solution to HW {#1}, Problem {#2}}}\\ \medskip {\it {#3}} % Name goes here \end{center}} \newcommand{\mysection}[1] {\noindent {\bf {#1}}} %%%%%% Begin document with header and title %%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} \myalgsheader \pagestyle{plain} \myhwtitle{1}{4 (3.2-2)}{Ben Bitdiddle} \bigskip %%%%% Begin Solution %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \noindent We must find an asymptotic upper bound on the summation \myzrfunction{S} defined by % Here's an example of how to do display equations. % \begin{equation} \label{a} S(n) = \sum_{k=0}^{\lfloor \lg n \rfloor} \left\lceil {{n} \over {2^k}} \right\rceil, \end{equation} \noindent whenever $n \in {\myZ}$. % First page break % Note: "myheadings" is a LaTeX keyword; it is not a user-defined entity. % \clearpage \setcounter{page}{2} \pagestyle{myheadings} \myrunninghwhead{1}{4} As a partial check on our work, in Table~\ref{tvalues} we computationally verify Equation~\ref{a} for $n=1,2$. % Here's an example of how to do tables. % \begin{table}[h] \label{tvalues} \begin{center} \begin{tabular}{|l|l|l|l|} $n$ & $2n-2$ & $S(n)$ & $2n+\lg n + 1$ \\ \hline $1$ & $2(1)-2=0$ & $\lceil 1/2^0 \rceil = 1$ & $2(1) + \lg 1 + 1= 3 $\\ $2$ & $2(2)-2 = 2$ & $\lceil 2/2^0\rceil + \lceil 2/2^1 \rceil = 2 + 1 = 3$ & $2(2) + \lg 2 + 1= 6$ \\ \hline \end{tabular}. \end{center} \caption{Values of $S(n)$ for $n = 1, 2$.} \end{table} \vfill \noindent {\it Acknowledgment: I thank Mary Lou for suggesting to use the method of splitting and bounding.} %%% End solution and document %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \end{document}