Monday, 2 June 2014

ArrayList Vs LinkedList

  1. ArrayList is faster than LinkedList to access elements randomly. ArrayList has direct references to every element in the list, so it can get the n-th element in constant time. LinkedList has to traverse the list from the beginning to get to the n-th element.
  1. LinkedList is faster than ArrayList for deletion.ArrayList is slower because it needs to copy part of the array in order to remove the slot that has become free. LinkedList just has to manipulate a couple of references.
  1. Access time for ArrayList: O(1). Access time for LinkedList: O(n).
  1. Deletion time for ArrayList: Access time + O(n). Deletion time for LinkedList: Access time + O(1).

Prevoius                                                 Next                                                 Home

No comments:

Post a Comment