in Algorithms
694 views
0 votes
0 votes

in Algorithms
694 views

4 Comments

@sakharam

your explanation was correct, it is θ( n4 ) only

@phaneendrababu

θ( n4 )  = O(n5) ----- it is also correct, but we choose lower bound always ===> it is θ( n4 )

0
0
edited by
The outer loop has 'n' iterations.For each outer loop the first inner loop has 'n^2' iterations,For some iterations of the first inner loop the second inner loop has 'n(n+1)/2' iterations. So,the time complexity is O(n)*O(n^2)*O(n^2)==>O(n^5).
2
2

Look at this once , this is from Narasimha Karumanchi ,IIT Bombay This the solution given by Narasimha Karumanchi , IIT Bombay. But m still confused !!!

2
2

1 Answer

0 votes
0 votes

Answer is  O(n4)

Related questions