0% found this document useful (0 votes)
10 views2 pages

Tut - 1 Asymptotic Complexity

tutorial on Asymptotic complexity

Uploaded by

saem habeeb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Tut - 1 Asymptotic Complexity

tutorial on Asymptotic complexity

Uploaded by

saem habeeb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Tutorial Questions

Week 1: Asymptotic complexity

Specific topics:
Asymptotic upper and lower bounds of algorithms, properties of asymptotic growth rates, some common
running times, and ordering of functions with respect to asymptotic behavior.

1. Order the following functions according to their order of growth (from the lowest to the highest).

(a) n n , 2n , n10 2n/2 , ni=1 (i + 1).
P

(b) n2 log n, n!, (3/2)n , n3/2 , nlog log n.


(c) (n − 2)!, 5 log(n + 100)10 , 22n , 0.001n4 + 3n3 + 1, log2 n, 3n .
2. Let f (n) and g(n) be asymptotically non-negative functions. Prove that

max{f (n), g(n)} = Θ(f (n) + g(n)).

3. Suppose that the functions f and g is such that f (n) is O(g(n)). Prove or disprove the following:
(a) log2 f (n) is O(log2 g(n))
(b) 2f (n) is O(2g(n) )
(c) f (n)2 is O(g(n)2 )
4. The Fibonacci sequence is a sequence of numbers recursively defined as follows:

F0 = 0, F1 = 1, Fn+2 = Fn + Fn+1

For example, the first few terms of the Fibonacci sequence are

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, . . . .

Prove the following for the recursive algorithm above to compute the nth Fibonacci number.
(a) T (Fn ) = O(2n )
(b) T (Fn ) = Ω(2n/2 ).
5. Consider the following procedure, which takes as input an array A:

1
Algorithm 1: The recursive function printStuff
Function printStuff(A):
n ← length of A
if n ≤ 4 then
return
for i = 0, . . . , n − 1 do
print A[i ]
printStuff (A[:n/4]) # recurse on first n/4 elements of A
printStuff (A[3n/4:]) # recurse on last n/4 elements of A
return

What is the asymptotic running time of printStuff?


6. What is the time complexity of the following code:
int i,j, k = 0;
for (i = n / 2; i<=n; i++) {
for (j = 2;j <= n; j=j*2) {
k = k + n / 2;
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy