0% found this document useful (0 votes)
6 views

Mod-1_Assignment_Final_1

The document outlines an assignment for CSE303: ADA, with a submission deadline of August 23rd. It includes various questions on asymptotic notation, time complexity analysis of algorithms, and comparisons of growth rates of functions. The assignment requires hand-written submissions and covers theoretical proofs and practical algorithm analysis.

Uploaded by

sshreyasaxenaa
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)
6 views

Mod-1_Assignment_Final_1

The document outlines an assignment for CSE303: ADA, with a submission deadline of August 23rd. It includes various questions on asymptotic notation, time complexity analysis of algorithms, and comparisons of growth rates of functions. The assignment requires hand-written submissions and covers theoretical proofs and practical algorithm analysis.

Uploaded by

sshreyasaxenaa
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

[CSE303: ADA] [Assignment-1]

[Submission deadline 23rd August [23.59 PM]


[Only hand-written assignments accepted (do not mail word file)]
Q1: Let f(n) and g(n) be asymptotically positive functions. Using the basic definition of O, Ω,
 and o(small-Oh). Prove or disprove each of the following conjectures.

a) 𝑓(𝑛) = 𝛩(𝑔(𝑛)) 𝑖𝑚𝑝𝑙𝑖𝑒𝑠 (𝑓(𝑛)) 𝑔(𝑛) = 𝛩(𝑔(𝑛))𝑓(𝑛) .


b) 𝑓(𝑛) + 𝑔(𝑛) = 𝛩(𝑚𝑎𝑥(𝑓(𝑛), 𝑔(𝑛))).
c) 𝑓(𝑛) = 𝑂(𝑔(𝑛)) 𝑖𝑚𝑝𝑙𝑖𝑒𝑠 lg (𝑓(𝑛)) = 𝑂(lg (𝑔(𝑛))),
𝑤ℎ𝑒𝑟𝑒 𝑙𝑔(𝑔(𝑛)) > 0 𝑎𝑛𝑑 𝑓(𝑛) ≥ 1 𝑓𝑜𝑟 𝑎𝑙𝑙 𝑠𝑢𝑓𝑓𝑖𝑐𝑖𝑒𝑛𝑡𝑙𝑦 𝑙𝑎𝑟𝑔𝑒 𝑛.
d) 𝑓(𝑛) = 𝑂(𝑔(𝑛)) 𝑖𝑚𝑝𝑙𝑖𝑒𝑠 2𝑓(𝑛) = 𝑂(2𝑔(𝑛) )
e) 𝑓(𝑛) = 𝑜(𝑔(𝑛)) 𝑖𝑚𝑝𝑙𝑖𝑒𝑠 2𝑓(𝑛) = 𝑜(2𝑔(𝑛) ), where o is the “small-oh” notation
f) 𝑓(𝑛) = 𝑂(𝑔(𝑛)) 𝑖𝑚𝑝𝑙𝑖𝑒𝑠 𝑔(𝑛) = 𝛺(𝑓(𝑛)).
2
g) 𝑖𝑓 𝑓(𝑛) = 𝑂(𝑔(𝑛)) 𝑎𝑛𝑑 𝑓(𝑛) = 𝛺(𝑔(𝑛) 𝑡ℎ𝑒𝑛, 𝑤𝑒 ℎ𝑎𝑣𝑒 (𝑓(𝑛)) = Θ((𝑔(𝑛))2 )
h) 𝑓(𝑛) = 𝛩(𝑓(𝑛/2)).
i) (𝑛 + 𝑎)𝑏 = Θ(𝑛𝑏 ) where a and b are constants.
j) if f(n) is o(g(n)) then it is always the case that f(n) is O(g(n))
k) if f(n) is O(g(n)) then it is always the case that f(n) is o(g(n))
l) if f(n)=o(g(n)) then log(f(n))=o(log(g(n))

Q.2 Consider the following 2 conditions (i) and (ii) for the function f(n), g(n) and h(n).
(𝑖) 𝑓(𝑛) = 𝑂(𝑔(𝑛)) 𝑎𝑛𝑑 𝑔(𝑛) ≠ 𝑂(𝑓(𝑛))
(𝑖𝑖) 𝑔(𝑛) = 𝑂(ℎ(𝑛)) 𝑎𝑛𝑑 ℎ(𝑛) = 𝑂(𝑔(𝑛))
Check which of the following statements are TRUE/FALSE, justify?
a) 𝑓(𝑛) = Θ(ℎ(𝑛))
b) 𝑓(𝑛) ∗ ℎ(𝑛) = 𝑂(ℎ(𝑛) ∗ 𝑔(𝑛))
c) ℎ(𝑛) = Θ(max {𝑓(𝑛), 𝑔(𝑛)})
d) ℎ(𝑛) ∗ 𝑔(𝑛) = Ω(𝑓(𝑛) ∗ 𝑔(𝑛))
e) 𝑓(𝑛) + 𝑔(𝑛) = 𝑂(ℎ(𝑛))
f) 2𝑓(𝑛) = 𝑂(2𝑔(𝑛) )

Q.3: Analyze the time complexity of the following Non-recursive and Recursive algorithm
(code).
a) for(i = 1; i  n; i + +) c) 𝑓𝑢𝑛( )
count = 0; {
for(i = 1; i  n; i* = 2) for( j = 1; j  n; j + +) 𝑖𝑛𝑡 𝑖 = 1; 𝑠 = 1;
𝑤ℎ𝑖𝑙𝑒(𝑠 <= 𝑛)
for( j = 1; j  n; j* = 2) j = j * 2; {
count = count + 1; 𝑖 + +;
𝑠 = 𝑠 + 𝑖;
𝑝𝑟𝑖𝑛𝑡𝑓("𝐴𝑚𝑖𝑡𝑦 𝑈𝑛𝑖𝑣𝑒𝑟𝑠𝑖𝑡𝑦");
}
}
d) 𝑒) 𝑖𝑛𝑡 𝑓𝑎𝑐𝑡(𝑖𝑛𝑡 𝑛) 𝑓)
A() { 𝑣𝑜𝑖𝑑 𝑇𝑒𝑠𝑡(𝑖𝑛𝑡 𝑛)
{ 𝑖𝑓(𝑛 == 0) {
int i,j,k,n 𝑟𝑒𝑡𝑢𝑟𝑛 1; 𝑖𝑓(𝑛 > 1)
for(i=1; i<=n;i++) 𝑒𝑙𝑠𝑒 {
{ 𝑟𝑒𝑡𝑢𝑟𝑛 𝑛 ∗ 𝑓𝑎𝑐𝑡(𝑛 − 1); 𝑓𝑜𝑟(𝑖 = 0; 𝑖 < 𝑛; 𝑖 + +)
for(j=1; j<=i2;j++) } {
{ 𝑝𝑟𝑖𝑛𝑡𝑓("Amity University");
for(k=1;k<=n/2;k++) }
{ 𝑇𝑒𝑠𝑡(𝑛/2);
printf("Amity"); 𝑇𝑒𝑠𝑡(𝑛/2); -
} } }
} } }

Q.4: Find which function is greater (asymptotically larger)

1. 𝑓(𝑛) = 𝑛2 𝑙𝑜𝑔𝑛 𝑔(𝑛) = 𝑛(𝑙𝑜𝑔𝑛)10


2. 𝑓(𝑛) = 3𝑛√𝑛 𝑔(𝑛) = 2√𝑛 𝑙𝑜𝑔𝑛
3. 𝑓(𝑛) = 𝑛𝑙𝑜𝑔𝑛 𝑔(𝑛) = 2√𝑛
4. 𝑓(𝑛) = 2𝑙𝑜𝑔𝑛 𝑔(𝑛) = 𝑛√𝑛
5. 𝑓(𝑛) = 2𝑛 𝑔(𝑛) = 22𝑛
Q.5 Arrange the following functions in increasing order of asymptotic growth rate.
𝑙𝑜𝑔𝑛 , (𝑙𝑜𝑔𝑛)10 , log(𝑙𝑜𝑔𝑛) , (log(𝑙𝑜𝑔𝑛))10 , 𝑛𝑙𝑜𝑔𝑛 , 𝑛√𝑛 , 10𝑛

Q.6 Use a Recursion tree (for Q.6(i) and 6(ii)) and Master method (for Q.6(iii), (iv)) and
change of variable for (6 (v)) to give an asymptotic tight solution to the recurrence

𝑛
(i) 𝑇(𝑛) = 3𝑇 ( 4) + Θ(𝑛2 )
(ii) 𝑇(𝑛) = 𝑇(𝑛 − 1) + 𝑇(𝑛 − 2) 𝑤𝑖𝑡ℎ 𝑇(0) = 0 𝑎𝑛𝑑 𝑇(1) = 1
𝑛
(iii) 𝑇(𝑛) = 2𝑇 ( 2) + 𝑛2 𝑙𝑜𝑔2 𝑛
𝑛 𝑛2
(iv) 𝑇(𝑛) = 2𝑇 (2) + 𝑙𝑜𝑔𝑛
1 𝑛=2
(v) 𝑇(𝑛) = {
√𝑛𝑇(√𝑛) + 𝑛 𝑛>2

Q.7 The recurrence 𝑇(𝑛) = 𝟗𝑇(𝑛/𝟐) + 𝑛2 describes the running time of algorithm A.
A competing algorithm A' has a running time of 𝑇′(𝑛) = 𝑎𝑇′(𝑛/𝟒) + 𝑛2 . What is the
largest integer value for 𝒂 such that A' is asymptotically faster than A?

***************************************************

You might also like