This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programming Diversions and the fly likes Algorithm Analysis Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "Algorithm Analysis Question" Watch "Algorithm Analysis Question" New topic
Author

Algorithm Analysis Question

Pavan Kumar Dittakavi
Ranch Hand

Joined: Feb 12, 2011
Posts: 104

Hi Guys,

If I have a method which has two O(n) operations, then what would be Order of the method itself? Is it sill O(n)?

Thanks,
Pavan.
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 2982
    
    9
If the method just calls the two operations one after the other, then yes, the result is O(n).

If the method has loops or if statements, the result may be different. For example if it loops n times and calls one or more O(n) operations, the result is O(n^2).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Algorithm Analysis Question
 
Similar Threads
Comparison of ArrayList and HashMap
grabage collection
Why & how to build map of maps?
pagination problem
most efficient way to remove duplicates from list?