below are some problems… pls provide the time complexity of the following snippets.
int count = 0;
for (int i = N; i > 0; i /= 2)
for (int j = 0; j < i; j++)
count++;
void function(int n)
{
int count = 0;
for (int i=0; i<n; i++)
for (int j=i; j< i*i; j++)
if (j%i == 0)
{
for (int k=0; k<j; k++)
// Print statement - O(1) operation
}
}
void pat(){
for ( int i = 2; i <=n; i = pow(i, c))
{
//Print statement - O(1) operation
}
//Here fun is sqrt or cube-root or any other constant root
for (int i = n; i > 1; i = fun(i))
{
//Print statement - O(1) operation
}
}
int a = 0;
for (i = 0; i < N; i++) {
for (j = N; j > i; j--) {
a = a + i + j;
}
}