Need help analyzing the runtime analysis of this algorithm/algorithms in general
I figured out why the runtime is O(N^2).

Yes, the while loop does run N/2 times. However, that is equivalent to -

"for(int i = 0; i &lt; N; i+=2)" which has a runtime of O(N) still.

I confused it with -

"for(int i = 0; i &lt; N; i *= 2)" which has a runtime of O(logN).

The summation also results in the correct answer in this instance.