Collaboration: You may work in groups of up to 3 students per group. Remember to clearly indicate the group members on your HW submission.
Submission: You should email your submission (preferably typed up in LaTeX but will also accept neatly handwritten) to cs350pdx@gmail.com
IMPORTANT: Provide an email subject line with the following pattern: HWx Section xxx - Full Name, Full Name, Full Name
Problem 1
List the functions below from lowest order of growth to highest. If any two or more are the same, indicate which.
n
m
2n
nlogn
n−n3+7n5
k2+logk
m2
n3
logn
n31+logn
(logn)2
n!
lnm
lognn
loglogk
(31)n
(23)n
6
Problem 2
Prove that for any positive integer constants a and b where b>0 (n+a)b∈Θ(nb)
(Hint: show that (n+a)b∈Ω(nb) and that (n+a)b∈O(nb) providing values for c1, c2, and n0.)
Problem 3
(From textbook 2.2 ex. 2) Use the informal definitions of O, Θ, and Ω to determine whether the following assertions are true or false.
n(n+1)/2∈O(n3)
n(n+1)/2∈O(n2)
n(n+1)/2∈Θ(n3)
n(n+1)/2∈Ω(n)
Problem 4
(From textbook 2.3 ex. 4) Consider the following algorithm:
Mystery Algorithm
Input: A non-negative integer n
Output: ?
S <- 0
for i <- 1 to n do
S <- S + i * i
return S
What does this algorithm compute?
What is its basic operation?
How many times is the basic operation executed?
What is the efficiency class of this algorithm?
Suggest an improvement, or a better algorithm altogether, and indicate its efficiency class. If you cannot do it, try to prove that, in fact, it cannot be done.
Problem 5
(From textbook 2.3 ex. 1) Compute the following sums.
1+3+5+7+...+999
2+4+8+16+...+1024
i=3∑n+11
i=3∑n+1i
i=0∑n−1i(i+1)
j=1∑n3j+1
i=1∑nj=1∑nij
i=1∑ni(i+1)1
Problem 6
(From textbook 2.4 ex. 1) Solve the following recurrence relations.