Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a . ( 1 0 pts ) Prove that if T ( n ) = 8 n 2 + 2 n + 1 5 ,

a.(10 pts) Prove that if T(n)=8n2+2n +15, then T(n)= O(n2). Hint: You need to find two
positive constant values c and n0 such that T(n)<= cn2 for all n >= n0.
b.(10 pts) Suppose the running time of an algorithm is 7n2+22m2+4nm +10m +200,
where n and m are positive integers such that n >= m. Prove that this algorithm is O(n2).
c.(20 pts) Give an analysis of the running time (Big-Oh notation) for the following
algorithms:
Firstly calculate T(n) and then find a tight upper bound (Big-Oh) for each algorithm. You do
not need to provide a proof.
sum =0;
i =0;
while(i < n){
sum+=i;
i+=3;
}
while(i >0){
sum-=i;
i-=2;
}
while(i < sqrt(n)*2){
sum+=i;
i++;
}
i =3*n;
while(i >0){
sum-=i;
i--;
}
print(sum);
sum =0;
i =0;
while (i < n){
j =1;
while (j <= n){
sum +=(i + j);
j++;
}
i*=2;
}
i =0;
while (i <10){
j =1;
while (j <= n){
sum -=(i + j);
j+=2;
}
i++;
}
i =0;
while (i <100000){
sum += i;
i++;
}
print(sum);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions