aspose file tools*
The moose likes Performance and the fly likes Time Complexity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "Time Complexity" Watch "Time Complexity" New topic
Author

Time Complexity

naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 692

hi All...

Suppose i have written a method like this


then what will be time complexity of my code...according to me it will be O(nlgn + n^2) ...is it correct ?


The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42584
    
  65
It's O(n ^2). Compared to n^2, n*log n is asymptotically irrelevant.


Ping & DNS - my free Android networking tools app
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11471
    
  16

in Big-O notation, you ignore all but the most significant term. so when you look at O(nlgn + n^2), the (n lg n) term grows so much slower than n^2, as n -> infinity, it really doesn't count for much. Therefore, you can safely ignore it.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 692

thanks ..appreciate your input....


so conclusion is ..its O(n^2) ....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Time Complexity