Essentially, that is what the loop boils down to.// 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}
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.