File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Time Complexity

 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's O(n ^2). Compared to n^2, n*log n is asymptotically irrelevant.
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12022
25
Chrome Java Linux
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks ..appreciate your input....


so conclusion is ..its O(n^2) ....
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic