tags:

views:

192

answers:

2

In theory, is it easier to remove elements from an ArrayList or a LinkedList ?

+6  A: 
erickson
+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