Difference between Array and Linked List
Array
An array is stored in sequential memory locations.
When adding a new item to the existing array, it is required to find new sequential memory locations. Although there is free memory space, arrays can not be stored if there are no sequential memory locations in which they could fit.
- Fast Read (Array items are stored in sequential memory locations)
- Slow Write (Arrays need to find new sequential memory locations)
Linked List
A linked list is a collection of structures ordered not by their physical placement in memory but by logical links that are stored as part of the data in the structure itself. It is not necessary that it should be stored in the adjacent memory locations.
- Slow Read (Keep tracking referenced nodes to get items)
- Fast Write (Add/Remove items by changing references)
Dynamic arrays
In most programming languages, there are clear differences in the way linked lists and arrays are stored in memory. Many scripting languages such as Python and Ruby offer dynamic arrays as a built-in primitive data type.
For More Details
Performance of Arrays vs. Lists | Stack OverflowUnderstanding the Difference Between Array and Linked List | Simplilearn
Array vs Linked List Data Structures | Level Up Coding