CS 477/677 Assignment 2
Due date: September 15, 2005, 11:30 AM.
All assignments must be handwritten (not typed or printed from a computer
file) in your own handwriting, on 8.5 by 11 inch paper, or on A4 paper.
Write your name on each sheet, and do not fold the pages or crimp the corners.
(You may use a paper clip or a staple.)
Turn the pages in to me or to the graduate assistant on or before the due date.
-
List the following functions in order of increasing asymptotic complexity.
If two or more functions have the same asymptotic complexity, say so.
-
n + log2n
-
n2
-
5n2+n-17
-
log2n
-
log10n
-
2log2n
-
n log n
-
log log n
-
n0.00001
-
2n
-
(1.00001)n
-
The nth Fibonacci number
-
log(n!)
-
n!
-
For each of the following code or pseudo-code fragments, write a recurrence
for the time complexity in terms of n, and then solve that recurrence.
Assume that all variables have type integer.
(See these problems, together with answers, for help.)
-
proc george(n)
while n > 0
{
write('I cannot tell a lie. I chopped down the cherry tree.');
n = n-1;
}
-
proc martha(n)
while n > 0
{
george(n);
n = n-1;
}
-
proc anthony(n)
if n > 0
{
george(n);
anthony(n/2);
}
-
proc cleopatra(n)
if n > 0
{
anthony(n);
cleopatra(n/2);
cleopatra(n/2);
}
-
proc bozo(n)
if n > 0
{
write('Hi there, folks!');
bozo(n-1);
bozo(n-1);
}
Back to
Course Page