The purpose of this assignment is to gain experience with the analysis tools we will be using throughout the semester. Because there is alot of math involved, you only need to submit this assignment on paper, in class on Friday. It can be hand-written if you prefer. However, make sure that whatever you submit is completely legible! Show work for partial credit. If you would like to submit it on Blackboard, that is also an option, but you MUST submit a hard-copy in class regardless.
You may need to brush up on some math skills, particularly regarding laws of exponents and logs, and also proof techniques. Review the classnotes from days 2-4 for details. The Weiss text, Chapter 2 contains formal definitions of the various asymptotic complexities that we are working with, and a math review. Wikipedia also has a very thorough explanation. The Sedgewick and Wayne text takes a slightly different approach in Chapter 1.4.
| Function | big Θ( ) | rank |
|---|---|---|
| (log N/4)3 |   |   |
| (N2-4) / (N+2) |   |   |
| (N + log N)3 |   |   |
| 3 log N2 |   |   |
| (2N)2 + log N |   |   |
| N2 log 16 |   |   |
| 2N log log N |   |   |
| 4N2 + N(10 + log N) |   |   |
a) [2]
sum = 0;
for ( i = 0; i < 2*N; i+=4)
sum += i;
b) [4]
sum = 0;
for ( i = N; i > 0; i /= 2)
for ( j = 0; j < i; j ++)
sum++;
c) [4]
sum = 0;
for ( i = 0; i < 3*N; i++)
for ( j = 0; j < 5; j++)
for ( k = i; k > 1; k--)
sum++;
d) [4]
sum = 0;
s = keyboard.nextLine(); // assume keyboard is an initialized Scanner
N = s.length();
v = "aeiou";
for ( i=0; i < v.length(); i++)
if ( s.indexOf(v.charAt(i)) >= 0)
sum++;
T1(N) + T2(N) = Ω(f(N) + g(N)) T1(N) * T2(N) = O(f(N) * g(N))
N-1 2i
SUM (3 - 4i + 6) =
i=0