CSC 344 - Algorithms and Complexity
Dr R. M. Siegfried
Assignment #2 - Working with Asymptotic Notation
Due Wednesday, February 1, 2017
- Select a theta (Θ) notation for each expression:
- 6n + 1
- 6n3 + 12n2 + 1
- 3n2 + 2n lg n
- 2 lg n + 4n + 3n lg n
- (n2 + lg n)(n + 1)/(n
+ n2)
- Select the theta notation for these code fragments (the choices are
Θ(1), Θ(lg n), Θ(n), Θ(n lg n),
Θ(n2), Θ(n3),
Θ(2n), and Θ(n!)):
for i = 1 to 2n
x = x + 1
for i = 1 to 2n
for j = 1 to i
x = x + 1
for i = 1 to n
for j = 1 to i
for k = 1 to i
x = x + 1
i = n
while (i ≥ 1) {
x = x + 1
i = i / 2
}
[Back to the Assignments Page]