Uploaded by o.s.b.c.1.designs

Alg20201 hw1

advertisement
Homework #1
Algorithms
Due Date: 07/12/2020
1. Find the time complexity of the following code segment, and then express
it in big-O notation.
i = 5;
while (i < n + 2) {
for (j = 2*n; j > 3; j--)
a = a  13;
k = 65;
for (j = 4; j < n+5; j = j+7) {
a = a + k/2 – 9;
k = k + 8*j;
} // end for j
i = i * 3:
} // end while
2. Solve the following recurrence relation using the iterative substitution
method:
T(n) = T(n/2) + 3
where n > 1, and T(1) = 5.
3. Solve the following recurrence relation using the Master Theorem method:
T(n) = 9T(n/3) + 4n2 + 7n
where n > 1, and T(1) = 1.
Important Note:
Please include the following information in your submitted homework.
Name:
Student Number:
Course: Algorithms
Section: Specify (Su, Tue, Th) or (Mon, Wed)
Homework #1
If you face a problem submitting homework through eLearning, you can
submit to my email: ayman@zuj.edu.jo
Dr. Ayman M. Abdalla
Download