Array
Numbered slots side by side, so reaching any one of them costs the same.
Result · step 2 of 6Array: Insert 7 at index 2
Move 8 from index 4 to index 5.
What you will see
INDEX -> CELL -> VALUE; insert shifts neighbours right, delete shifts left.
Cost
| access | O(1) |
|---|---|
| search | O(n) |
| insert | O(n) |
| delete | O(n) |
| Space | O(n) |
Insert and delete at the end are O(1) when capacity allows.
How you work with it here
play it through, step one change at a time, scrub to any step, run it on your own input, try operations in any order.
Screen readers: Each element is an accessibility element with position, value and state; structural changes are announced per step.
Reduced motion: Elements appear at their destination with a crossfade; no travel longer than the element's own size.
Related
Leads to
Topics that need this one first.
Adjacency ListBinary HeapDynamic ArrayHash TableQueueSingly Linked ListStackStringCircular QueueDisjoint Set UnionEdge ListFenwick TreeMatrixSegment TreeBitsetArray DeleteArray InsertArray SearchArray TraversalPrefix SumReverse ArrayBinary SearchLinear SearchBubble SortInsertion SortMerge SortSelection SortSliding WindowTwo PointersRange Minimum QuerySieve of Eratosthenes
Taught by the same lesson
Array covers these too, in the same run.