Docsity

Asymptotic Notation-Theory of Complexity and Algorithms-Assignment Solution, Exercises of Advanced Algorithms

Toggle sidebar
bg1
Asymptotic notation
Put these functions in order so that if f(n)∈O(g(n)) (i.e. f(n) is Big-Oh
of g(n)), then f(n) appears before g(n) in the list. Group together functions
that have the same asymptotic order of growth (i.e. f(n)∈Θg(n)).
n2, n log n, n3+ log n, √n, n2+ 2nlog n,
log log n, 17 log n, 10n3
2, n5−n4+ 2n,
5n2log log n, 3n2+n3log n, n + 6 log n
Solution: Here is the list, where I have grouped together the functions
having the same asymptotic order of growth (there’s only one such pair):
log log n, 17 log n, √n, n + 6 log n, n log n,
10n3
2,{n2, n2+ 2nlog n},5n2log log n,
n3+ log n, 3n2+n3log n, n5−n4+ 2n
Essentially, most of these can be demonstrated using the fact that log n≤
nfor all n≥1, and hence, log logn≤log n(for all n≥2, why the change
to n≥2 ??).
Also, we know that log n≤√nfor all n≥1. If you know any calculus,
this is easy to prove. First show that limn→∞
log n
n= 0 using L’Hˆopital’s
Rule. This means that lognis Little-Oh of n, and, as mentioned in class,
this implies that log nis Big-Oh of n. (I basically said that you an assume
the fact that log nis Big-Oh of n, and that log nis Big-Oh of n1
kfor all
k≥1.)
We can easily make statements like 2nlog n≤2n2≤2n2log log nfor
large enough n. Similarly, n3log n≤n4≤n5−n4for “large enough” n.
These statements can be more formally proved.
Recall also that n3
2=n·n1
2=n·√n.
1
docsity.com

Partial preview of the text

Download Asymptotic Notation-Theory of Complexity and Algorithms-Assignment Solution and more Exercises Advanced Algorithms in PDF only on Docsity!

Asymptotic notation

Put these functions in order so that if f (n) ∈ O(g(n)) (i.e. f (n) is Big-Oh of g(n)), then f (n) appears before g(n) in the list. Group together functions that have the same asymptotic order of growth (i.e. f (n) ∈ Θg(n)).

n^2 , n log n, n^3 + log n,

n, n^2 + 2n log n,

log log n, 17 log n, 10 n

(^32) , n^5 − n^4 + 2n,

5 n^2 log log n, 3 n^2 + n^3 log n, n + 6 log n

Solution: Here is the list, where I have grouped together the functions having the same asymptotic order of growth (there’s only one such pair):

log log n, 17 log n,

n, n + 6 log n, n log n,

10 n

(^32) , {n^2 , n^2 + 2n log n}, 5 n^2 log log n,

n^3 + log n, 3 n^2 + n^3 log n, n^5 − n^4 + 2n

Essentially, most of these can be demonstrated using the fact that log n ≤ n for all n ≥ 1, and hence, log log n ≤ log n (for all n ≥ 2, why the change to n ≥ 2 ??). Also, we know that log n ≤

n for all n ≥ 1. If you know any calculus, this is easy to prove. First show that limn→∞ logn^ n = 0 using L’Hˆopital’s Rule. This means that log n is Little-Oh of n, and, as mentioned in class, this implies that log n is Big-Oh of n. (I basically said that you an assume

the fact that log n is Big-Oh of n, and that log n is Big-Oh of n

1 k (^) for all

k ≥ 1.) We can easily make statements like 2n log n ≤ 2 n^2 ≤ 2 n^2 log log n for large enough n. Similarly, n^3 log n ≤ n^4 ≤ n^5 − n^4 for “large enough” n. These statements can be more formally proved. Recall also that n

3 (^2) = n · n

1 (^2) = n ·

n.

docsity.com