Hey there, I’m preparing for a test with a friend
And we came across this question from an earlier test
Gemini and gpt give different answers
Would love some advice
I need to calculate the time complexity range of this code:
I think it’s n^3 c *( logc of n)
He thinks it’s n^4 logc of n
And we came across this question from an earlier test
Gemini and gpt give different answers
Would love some advice
I need to calculate the time complexity range of this code:
I think it’s n^3 c *( logc of n)
He thinks it’s n^4 logc of n
Code
int func(int n, int c){
int s=0, m=0;
for(int i=4; i<n*n; i++){
for(int j=5; j<c*i; j*=c){
if(j^(c*n-1)){
for(int k=0;k<c*n;k++)
m++;
break;
}
for(int k=0;k<c*n;k++)
s++;
}
}
return s>m? s:m;
}
