1. Memory Allocation

ArrayList uses Array as underline datastructure to store the elements, and we know Array stores elements in consecutive manner. In LinkedList, elements can be stored at any available memory location as address of node is stored in previous node.

Memory Allocation
Memory Allocation

2. Element Retrieval

Element retrieval in ArrayList is much faster then LinkedList, ArrayList take O(1) of time to retrieve any location where LinkedList take O(n) time to retrieve the element.

3. Element Manipulation

Element manipulation with ArrayList is slow because it uses internally Array, For storing or removing of any new element needs to shift other elements in Array.

Example :

If we want to delete element at index 3.

Remove Element at index 3
Remove Element at index 3

Element manipulation with LinkedList is fast compare to ArrayList, For storing or removing of new element needs to update the node address only.

4. Role as a Queue

ArrayList can be act as List only as it implements List interface only, Where LinkedList can be act as List and Queue also as it implements List and Deque interface.

Object 1 Object 2

5. Example of ArrayList and LinkedList

arraylist: [Tom, Jerry, Devin] linkedlist: [Walter, Mark, Elon]

Leave a Reply

Your email address will not be published. Required fields are marked *