I'm trying to figure out the running time of the code below, both if the list was an arraylist and if it was a linkedlist. I appreciate any advice!
Array: I thought it would be O(n) for remove operation, and N/2 for the loop, so O(n^2)
LinkedList: Only references change, so constant time for the remove and N/2 for the loop, so O(n)
int halfSize = lst.size() / 2;
for (int i = 0; i < halfSize; i++){
lst.remove(0);
}