IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New OK, a bit less of a cursory glance...
// As always, assume n elements\nfor (int i = theArray.length-1; i > 0; i--) { // This is n\n  for (int j = 0; j <= i; j++) { // This is n\n    for (int k = 0; k <= i; k++) { // And this is n\n    }\n  }\n  for (int j = maxIndex; j < i; j++) { // This is also n, but it's not nested\n  }\n}
Essentially, that is what the loop boils down to.

The first three loops are N, and they're all nested. So that gives you N^3. There's also that second loop. That's nested at the second level. So taking that with the "i" loop, that would make the loop (ignoring the other parts) N^2. So you've got something that's O(N^3) + O(N^2). The cubed strongly overpowers the squared, so it's common just to toss that out.

-YendorMike

[link|http://www.hope-ride.org/|http://www.hope-ride.org/]
New Yes, I've come to that conclusion too
Thanks for the discussion on it; it helped me in my thinking. I'm writing the test program now to actually prove that this is the case.
--\r\n-------------------------------------------------------------------\r\n* Jack Troughton                            jake at consultron.ca *\r\n* [link|http://consultron.ca|http://consultron.ca]                   [link|irc://irc.ecomstation.ca|irc://irc.ecomstation.ca] *\r\n* Kingston Ontario Canada               [link|news://news.consultron.ca|news://news.consultron.ca] *\r\n-------------------------------------------------------------------
New Just so you know
The result of my instrumentation showed it to be n^3. The results were good to a pretty high degree of precision; the IBM JDK was really consistent once I turned of the JIT compiler. I used the 1.1.8 JVM for my test runs.

Thanks again for the help, Mike!
--\n-------------------------------------------------------------------\n* Jack Troughton                            jake at consultron.ca *\n* [link|http://consultron.ca|http://consultron.ca]                   [link|irc://irc.ecomstation.ca|irc://irc.ecomstation.ca] *\n* Kingston Ontario Canada               [link|news://news.consultron.ca|news://news.consultron.ca] *\n-------------------------------------------------------------------
New Glad to help! :)
-YendorMike

[link|http://www.hope-ride.org/|http://www.hope-ride.org/]
     Fun with complexity - (jake123) - (8)
         Just doing a cursory glance at it... - (Yendor) - (1)
             Yeah, I was wondering about that. - (jake123)
         OK, a bit less of a cursory glance... - (Yendor) - (3)
             Yes, I've come to that conclusion too - (jake123) - (2)
                 Just so you know - (jake123) - (1)
                     Glad to help! :) -NT - (Yendor)
         my favourite sort algorithm is... - (cforde) - (1)
             Freak -NT - (tuberculosis)

class Lrpdism(GenericSaying):
101 ms