DSA Array list vs linked list

Here’s a short and clear tabular comparison of ArrayList and LinkedList in English:

FeatureArrayListLinkedList
Storage MechanismUses a dynamic array internally.Uses a doubly linked list internally.
Access TimeFast for random access (O(1) for get).Slow for random access (O(n) for get).
InsertionSlow for inserting in the middle (O(n)).Fast for inserting anywhere (O(1)).
DeletionSlow for deleting in the middle (O(n)).Fast for deleting anywhere (O(1)).
Memory UsageLess memory as it stores only data.More memory as it stores node pointers too.
IteratingFaster with for loop.Slower, requires traversal of nodes.
Use CaseBest for read-heavy operations.Best for insert/delete-heavy operations.
ResizableAutomatically resizes when full.Dynamically grows with new nodes.

Code for arraylist:

alt text

code for linkedlist

alt text