I do not know how to get exact Asymptotic Complexity as following question asks me to solve.
Here is Question:
Everything I learned from class is that, if there exists "for loop" that runs N times, or recursively call "recursive method" N times, then either one is O(N). This is practically all the base knowledge I know of.
Question 1) What answer says about "N(N+1)/2", is this same as "O(N(N+1)/2)"?
Also, the answer says followng "On iteration i, both add and trimToSize require that i array elements be copied to a new array.", I think it says this because it calls both "list.add()" and "list.trimToSize()" N times.
From my perspective, this looks more like just O(N)... because since it adds ith element N times using "list.add()" and also array-copies element N times through "list.trimToSize()". Thus, N + N <= 2N so O(N) where witness C=2 and k=1, not O(N(N+1)/2). However, my answer is wrong. Therefore,
Question 2) I just do not know how to obtain N(N+1)/2 as answer says.
Thank you very much if you can answer!