Question
Need in detail solution of the problem below: Given the following source code where n = number of data points: for( int i = 0;
Need in detail solution of the problem below:
Given the following source code where n = number of data points:
for( int i = 0; i < 100*n; ++i) { // cost for line?
for( int j = 0; j < 50*n; ++j) { // cost for line?
sum += i*j; // cost for line?
}
}
It is found the cost function of the code is:
T(n) = c0*(100*n + 1) + c1*(100*n)*(50n + 1) + c2*100n*50n.
Reducing and collecting produces:
T(n) = c0*100n + c0 + c1*5000n^2 + c1*100n + c2*5000n^2
T(n) = c0 + c0*100n + c1*100n + c1*5000n^2 + c2*5000n^2
T(n) = (c0 + c0*100 + c1*100)n + (c1*5000 + c2*5000)n^2
Replacing the constant terms with the values c3 = c0 + c0*100 + c1*100 and c4 = c1*5000 + c2*5000.
Produces:
T(n) = c4*n2 + c3*n
Determine which is true:
For any c3,c4 > 0 is it true T(n) (n2) as n-> .
For any c3,c4 > 0 is it true T(n) q(n2) as n-> .
For any c3,c4 > 0 is it true T(n) O(n2) as n-> .
Show all logic and work using the inequality proof tests:
i.e. for f(n) O(g(n)) show that f(n) <= c*g(n) where c > 0 as n-> .
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started