Main differences between ArrayList and LinkedList data structures are:
- Data Structure: An ArrayList is an indexed based dynamic array. A LinkedList is a Doubly Linked List data structure.
- Insertion: It is easier to insert new elements in a LinkedList, since there is no need to resize an array. Insertion in ArrayList is O(n), since it may require resizing of array and copying its contents to new array.
- Remove elements: LinkedList has better performance in removal of elements than ArrayList.
- Memory Usage: LinkedList uses more memory than ArrayList, since it has to maintain links for next and previous nodes as well.
- Access: LinkedList is slower in accessing an element, since we have to traverse the list one by one to access the right location.
Comments
Post a Comment