See how array operations work step by step, with a live step log explaining each move.
Length: 5 / 10
Add a value to the end. No other elements move.
$ Run an operation above to see step-by-step narration here.
| Operation | Time Complexity | Why |
|---|---|---|
| Access by index | O(1) | Memory address is calculated directly from the index. |
| Push / Pop (at end) | O(1) | No other elements need to move. |
| Remove | O(n) | Elements after the index must shift left by one position. |
| Linear search | O(n) | Every element may need to be checked in the worst case. |
Pick an operation tag (Push, Search, Update, Remove, Pop, or Clear). Hover a tag to see its complexity and what it does.
Enter a value or index where needed, then run it. Pop and Clear run immediately since they need no input.
Watch the boxes animate and read the step log below to see exactly what the array does.
An array is a data structure that stores a fixed-size, ordered collection of values in contiguous memory. Each value has an index starting from 0, so any value can be accessed directly using its index.
Pushing to the end (or popping from the end) doesn't affect any other value, so it's O(1). Removing at an earlier index means every value after it has to shift over by one position to keep the array contiguous, which takes O(n) time in the worst case.
Linear search checks each element one by one starting from index 0 until it finds a match or reaches the end. In the worst case (value not present, or it's the last element), it checks all n elements.