Empleador activo
What's the difference between arraylist and linkedlist in Java?
Anónimo
An ArrayList has an underlying array. Access is by index, O(1). Appending is amortized O(1), because the size of the array must be periodically increased. That requires an O(n) copy of all elements. Insertion and deletion are worst case O(n) because it requires all elements after the inserted or deleted elements to be shifted. LinkedList access is O(n), because the list must be traversed. Appending is O(1): change the last.next pointer. Insertion and deletion are also accomplished by pointer shuffling: O(1). Because a LinkedList maintains two pointers for each data element, it's memory overhead is higher than that required by the ArrayList's indexes.