edited by
138 views

1 Answer

0 votes
0 votes

Time complexity will be O(n log5n ) because.

1. The inner loop is independent of the outer loop. For each value of  i  It will run log5n each time.

so, for n times it will be = O(n log5n ).

for(i=1;i<=n;i++) =================================== O(n)
    {
        for(j=1;j<=n;j=5*j) { ==============log
5n {p = p + n; } }

Because inner loop doesn't depend on the on the outer loop so, directly multiply here O(n log5n ).

Related questions

1 votes
1 votes
1 answer
1
sumitr asked Apr 10, 2019
1,328 views
What is the best case and worst case of the algorithm? And when will best case and worst case will happen??int main() { for(i=1 ; i<=n ; i++) { if(n%i == 0) { for(j=1 ; j...
0 votes
0 votes
3 answers
2
Nisha Bharti asked Sep 26, 2022
752 views
What is the time & space complexity of this algorithm?Main(){ for(i=n; i>10; i=i^1/4) { for(j=201; j<n^3; j=j+400) ...
0 votes
0 votes
1 answer
3
tusharb asked Feb 18, 2022
713 views
As we know the time complexity of solving the greedy knapsack algorithm depends mainly on the sorting algorithm used, Can we use counting sort as the sorting algorithm to...
0 votes
0 votes
1 answer
4
eyeamgj asked Sep 3, 2018
556 views
https://gateoverflow.in/1036/gate2004-39WHAT IS DIFFERENCE BETWEEN TYM COMPLEXITY AND PROGRAM EXECUTION TIME??