- 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.
- 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.
- Access time for ArrayList: O(1). Access time for LinkedList: O(n).
- Deletion time for ArrayList: Access time + O(n). Deletion time for LinkedList: Access time + O(1).
No comments:
Post a Comment