edited by
896 views
1 votes
1 votes

The difference of time Complexity between given functions can be represented by:

void fun1(int n)

{

    for(int i=1;i<=n;i++)
     for(int j=1;j<=i*i;j++)
     if(j%i==0)
        for(int k=1;k<=j;k++)
         s++;
    return 0;
}

void fun2(int n)

{

    for(int i=1;i<=n;i++)
     for(int j=1;j<=i*i;j++)
        for(int k=1;k<=j;k++)
         s++;
    return 0;
}

$i. O(n^2)$

$ii. O(n)$

$iii.O(1)$

$iv. O(n^{1.5})$

edited by

1 Answer

1 votes
1 votes

According to me,

for function fun1 complexity is O(n^4) and for fun2 its O(n^5)

hence difference being 0(n)

edited by
Answer:

No related questions found