I want to calculate the order of this function, I calculated but I'm not sure if this right.
This is the function
int fct (int Y){
int y = 0 ;
for ( int i =0; i<Y;++ i ){
for ( int j=i ; j >=0;--j ){
y++;
}
}
return y ;
}
And this is my calculus:
For Inner Loop
\1+1+sum_{j=i}^{n-1}(1+1+1)=3n-1
For First loop
\1+1+sum_{i=o}^{n}(3n-1+1)=3n^{2}+2
Finally 3n^{2}+1+2=3n^{2}+3= O(n^{2})
Its right this solution?
Thanks