Answer to Question #84587 in Algorithms for ML.R

Question #84587
Find the time complexity of the following algorithms in terms of Big O.
1) Time Complexity of a loop if the loop variables is divided / multiplied by a constant amount as follows:
for (int i = 1; i <=n; i *= c) {
// some O(1) expressions
}
2) Time Complexity of a loop if the loop variables is reduced / increased exponentially by a constant amount as follows:
// Here c is a constant greater than 1
for (int i = 2; i <=n; i = pow(i, c)) {
// some O(1) expressions
}
//Here fun is sqrt or cuberoot or any other constant root
for (int i = n; i > 0; i = fun(i)) {
// some O(1) expressions
}
3) What is the returned value of the following function?
int Fun(int n) {
int i, j, k = 0;
for (i = n/2; i <= n; i++)
for (j = 2; j <= n; j = j * 2)
k = k + n/2;
return k;
}
1
Expert's answer
2019-01-28T03:01:18-0500
Dear ML.R, your question requires a lot of work, which neither of our experts is ready to perform for free. We advise you to convert it to a fully qualified order and we will try to help you. Please click the link below to proceed: Submit order

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS