Homework #3
Due: Thursday, Sept. 26, 2002
Chapter 1. Exercises 22, plus determine the theta notation for the following sections of code:
Code A:
i := n
while (i >= 1) do
for j := 1 to i do
for k := 1 to n do
some code that takes time
end for k
end for j
i := i / 2
end while
Code B:
for i := 1 to n do
for j := 1 to i do
for k := j to (i + j) do
some code that takes time
end for k
end for j
end for i
Code C:
i := n
while i > 0 do
for k = 1 to n do
j := 1
while j < i do
some code that takes time
j := j * 2
end while
end for
i := i / 2
end while
Ch 2. Exercise 7 give recurrence and solve the recurrence, 15, 39 give recurrence and solve the recurrence
Appendix B. 12b, 12c, 15c, 15d
For all of the exercises we are after the theta notation so you don't need to solve for the ci constants!