Bifalgorithm post
"An array is one of the most common ways to store a list, but it's not the best option for every scenario. An array stores every element right next to each other in memory. That allows any element to be accessed almost instantly by using its index to calculate its location in memory. But when you need to insert or remove an element, arrays become much less efficient. Every element after it has to be shifted over to keep the array contiguous in memory. Each element stores a pointer to the next one, creating a chain. That makes inserting or removing an element much faster. Instead of shifting every following element, you just reconnect the pointers before and after it. The downside is that you can't instantly access an element. You need to start at the very beginning of the list, following every pointer leading up to it. So for fast access..."
"An array is one of the most common ways to store a list, but it's not the best option for every scenario. An array stores every element right next to each oth…
Ideas in this flowchart
- Array vs. Linked List
- Array Characteristics
- Contiguous Memory Storage
- Fast Element Access
- Inefficient Insert/Remove
- Linked List Characteristics
- Pointer Chain
- Efficient Insert/Remove
- Slow Element Access