Array vs Linked List
An array keeps its items side by side in memory, so reading any one is instant. A linked list joins items with pointers. Changes in the middle are quick, but reading is slow.
Array
A row of values kept together under one name. Each sits in a numbered spot.
An array is one value that holds many values in a row. Each item sits in a numbered spot, and the count starts at zero. You can add items, take them out, sort them or go through them one by one. Python calls its array a list. Arrays are the most common way to keep many things of the same kind together.
Linked List
A chain of items. Each one holds a value and points to the next.
A linked list is a chain of items that point to each other in a line. Each item holds a value and a pointer to the next one. The items do not sit side by side in memory; the pointers join them. Adding or removing an item in the middle is fast, because you only change two pointers. Reaching the 500th item is slow, because you must follow 499 pointers. A doubly linked list also points back to the item before.
In one line
- Array
- A row of values kept together under one name. Each sits in a numbered spot.
- Linked List
- A chain of items. Each one holds a value and points to the next.