-1

What will be the time complexity?

`

for(int i=0;i<n;i++){
        for(int j=i;j<i*i;j++){
            for(int k=0;k<j;k++){
                System.out.println("*")
            }
        }
    }

`

Ankur Bose
  • 29
  • 5
  • Does this answer your question? [How to find time complexity of an algorithm](https://stackoverflow.com/questions/11032015/how-to-find-time-complexity-of-an-algorithm) – Paul Hankin Apr 28 '20 at 13:46
  • @PaulHankin Actually i am confused whether it should be O(n^2) or not? – Ankur Bose Apr 28 '20 at 16:34

1 Answers1

0
**                                                                                                                                                       
***                                                                                                                                                      
***                                                                                                                                                      
****                                                                                                                                                     
*****                                                                                                                                                    
******                                                                                                                                                   
*******                                                                                                                                                  
********                                                                                                                                                 
****                                                                                                                                                     
*****                                                                                                                                                    
******                                                                                                                                                   
*******                                                                                                                                                  
********                                                                                                                                                 
*********                                                                                                                                                
**********                                                                                                                                               
***********                                                                                                                                              
************                                                                                                                                             
*************                                                                                                                                            
**************                                                                                                                                           
***************  

when n = 5, which leads me to believe it is O n^4:

For i = 0 to n      ->n
For j = i to i*i    ->max times is n sqr
For k = 0 to j      ->n

I may be wrong, I'm not yet an expert at big O, but thanks for reading :)

yozaam
  • 79
  • 6