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})$ Algorithms time-complexity asymptotic-notation algorithms + – shreyansh jain asked Jan 4, 2019 • edited Jan 4, 2019 by shreyansh jain shreyansh jain 904 views answer comment Share Follow See all 7 Comments See all 7 7 Comments reply Shaik Masthan commented Jan 4, 2019 reply Follow Share https://gateoverflow.in/230638/ace-algorithms 0 votes 0 votes kumar.dilip commented Jan 4, 2019 reply Follow Share Shaik Masthan For the first function number of time, the inner loop will execute will be $\frac{n^{2}*(n+1)}{2}$ So, the complexity will be O(n^3). 0 votes 0 votes Shaik Masthan commented Jan 4, 2019 reply Follow Share did you checked the link ? 0 votes 0 votes kumar.dilip commented Jan 4, 2019 reply Follow Share I didn't sum up all the terms. Just a calculation mistake. O(n^4) is right. 0 votes 0 votes Shreya kumari commented Jan 10, 2019 reply Follow Share @Shaik MasthanCan u please tell me what is the meaning of difference of time complexity between functions here? 0 votes 0 votes Shaik Masthan commented Jan 11, 2019 reply Follow Share if f$_1$ is O(n$^k$) and f$_2$ is O(n$^p$) then we can say the difference is O(n$^{|k-p|}$) 0 votes 0 votes RRaushan commented Mar 23, 2019 reply Follow Share For f1 time complexity see this : https://gateoverflow.in/230638/ace-algorithms 0 votes 0 votes Please log in or register to add a comment.
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) rish1602 answered Jul 9, 2021 • edited Aug 4, 2021 by rish1602 rish1602 comment Share Follow See all 0 reply Please log in or register to add a comment.