In theory, is it easier to remove elements from an ArrayList or a LinkedList ?
views:
192answers:
2
+3
A:
Well, removal of an element from a (doubly-linked-)list is O(1). But removal from an array will require that the remaining elements are shifted down one space in the array, which is O(n).
That said, getting a specific element in a list by index is O(n), while getting a specific element in an array by index is O(1).
So, the for actual removal, List will be better. There is more info on Array's versus List here.
GMan
2009-06-23 20:57:28