Is the complexity of the above code N or N^2?Code:m = 0;
for (i=1; i<n; i = 2*i)
m = m + i;
I believe its N since the variable m wont effect the time of the function.
An I believe complexity of this function is NCode:i = 1;
while ( i < n )
{
if( i % 2 == 0 )
m = m * i;
i++;
}
The complexity of this function is N^2.Code:for (i = 0; i < n; i++ )
for ( j=0; j < i; j++ )
printf( “i = %d and j = %d\n”, i, j );