The i loop makes the j loop run i times, where i is going to be equal to n + (n-1) + (n-2) + ... + 1 times. In turn, each run of the j loop makes the k loop run i the same number of times. The loop at the bottom for moving the array members around should run on average n/2 times; it's not important, right? So, really you're looking at (n + (n-1) + (n-2) + ... + 1)^2. Yes...?