\documentclass[11pt]{article}
\usepackage{fullpage} 
\usepackage{graphicx} 
\usepackage{clrscode3e} 
 
 
 
 
\begin{document} 
 
\title{Algorithms Lab 1} 
 
\date{} 
\maketitle 
 
 
 
The in-lab problems are to be solved during the lab time.  Work with 
your team, but write your solutions individually. You do not need to 
turn in your answers, only discuss them with me. Ask me for feedback 
on how you write your answers as well. 
 
The homework problem set is due on Friday, 9/18. Work with your team, but 
write your solutions individually. List the people with whom you 
discussed the problems. 
 
 
 
\section{ In lab exercises} 
 
\begin{enumerate}  
 
%\item Consider the problem of finding the index of the smallest 
%  element in an array of n elements.  We discussed an algorithm 
%  for solving this problem in class. Express, as a function of $n$, the 
%  best-case and worst-case running time of this algorithm.  
% 
%\item Express, as a function of $n$, the best-case and worst-case 
%  running time of selection sort. Use the answer from (1). It's ok to 
%  leave the answer as a summation. 
 
\item Algorithm A uses $10 n \lg n$ operations, while algorithm B uses 
  $n^2$ operations. Determine the value $n_0$ such that A is better 
  than B for $n \ge n_0$. 
 
\item Let $f(n) = \lg n$ and assume that we have an algorithm whose 
  running time is $f(n)$ microseconds.  Determine the largest size of 
  a problem that can be solved by the algorithm in: (a) 1 second; (b) 
  1 hour; (c) 1 month; (d) 1 century. 
 
 
  Same problem for $f(n) = n$ and $f(n) = 2^n$.  
 
\item 
Show that $a n^2 + b n + c$ is $O(n^2)$ (where $a$, $b$, and $c$ are constants).  Assume that $a > 0$; $b$ and $c$, however, might be 0 or negative. Hint: Use absolute values. 
 
\item Order the following expressions from fastest to slowest:  
   
$$ \sqrt 2 ^ {\lg n}, n^2, {(\frac{3}{2})}^n, n^3, \lg n ^2,  \lg^2 n,  2^n, \lg \lg n, n \lg n$$ 
 
\item  
Suppose you have algorithms with these five running times: 
\begin{enumerate} 
\item $n^2$ 
\item $100 n^2$ 
\item $n^3$ 
\item $ n \lg n$ 
\item $2^n$ 
\end{enumerate} 
 
How much slower do each of these algorithms get when you increase the input size by one? 
 
 
 
\end{enumerate} 
 
 
\section{Homework problems} 
 
Your assignment will be evaluated based not only on the final answer, but 
also on clarity, neatness and attention to details. For example, you'll 
want to leave plenty of space in between problems so that we can give you 
feedback. 
 
\begin{enumerate}  
 
\item Describe a method for finding both the minimum and the 
  maximum of $n$ numbers with fewer than $3n/2$ comparisons. 
 
\item Give an example of a positive function $f(n)$ such that 
  $f(n)$ is neither $O(n)$ nor $\Omega(n)$. 
   
\item Arrange the following functions in ascending order of growth 
  rate. For each pair of consecutive functions, give a brief 
  justification on why they are in this order.  For e.g., if you 
  ordered $A,  B, C$, you need to justify that 1. $A = O(B)$; and 
  2. $B = O(C)$. 
 
$$ 2^{\sqrt {\log n}}, 2^n, n^{4/3}, n (\log n)^3, n ^ {\log n}, 
2^{2^n}, 2^{n^2} $$ 
 
% \item (GT R-1.6) Order the following list of functions in ascending 
%   order of growth by the big-Oh notation.  Group together those 
%   functions that are big-Theta of one another. For each pair of 
%   consecutive functions, give a brief justification on why they are in 
%   this order.  For e.g., if you ordered $A < B < C$, you need to 
%   justify that $A < B$ and  $B < C$. 
 
% $$6 n \lg n, 2^{100}, \lg \lg n,  \lg^2 n, 2^{\lg n}, 2^{2^n},  
% \sqrt n,n^{0.01},  1/n, 4n^{3/2},$$  
 
% $$3n^{0.5}, 5n, 2n\lg^2 n, 2^n, n \log_4 n, 4^n, 
% n^3, n^2 \lg n, 4^{\lg n}, 4^{\lg n}, \sqrt {\lg n}$$ 
 
\item 
Suppose each row of an $n \times n$ array $A$ consists of 1's and 0's such that, in 
any row $i$ of $A$, all the 1's come before any 0's. Assuming $A$ is already in memory, describe a method running in $O(n)$ time (\emph{not} $O(n^2)$ time) for finding the row of $A$ that contains the most 1's. 
 
 
 
\item  
Suppose you have algorithms with these five running times: 
\begin{enumerate} 
\item $n^2$ 
\item $100 n^2$ 
\item $n^3$ 
\item $ n \lg n$ 
\item $2^n$ 
\end{enumerate} 
 
How much slower do each of these algorithms get when you double the input size? 
 
 
\end{enumerate} 
 
 
 
\end{document} 
%%% Local Variables:  
%%% mode: latex 
%%% TeX-master: t 
%%% End:  
