Question: Find and explain the time complexity (Big-Oh notation) for the following code snippet? [Points: 6] double y = 0; for( int i = 1; i
Find and explain the time complexity (Big-Oh notation) for the following code snippet? [Points: 6]
double y = 0; for( int i = 1; i <= n; i++ ){
for(int j = 1; j <= m; j++){ y += j*log(2);
} }
If n=m then what will be time complexity of the above nested iteration in Q2.a? [Points: 2]
Find and explain the time complexity (Big-Oh notation) for the following code snippet? [Points: 6]
long y = 0L; for( int i = 1; i <= n; i++ ){
for(int j = 1; j <= m; j++){ y += log(j);
} }
[Note: log(LxMxN)=logL+logM+lognN]
Find and explain the time complexity (Big-Oh notation) for the following code snippet? [Points: 6]
long y = 0L; for( int i = 1; i <= n; i++ ){
for(int j = 1; j <= n; j++){ y += factorial(j); //where factorial is a function that calculates the factorial value
//of the given number
} }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
