Data Structures and Algorithms — Interactive
Array
Contiguous memory blocks. Access any element in O(1) using its index — the backbone of all data structures.
Access O(1)Search O(n)Insert O(n)Space O(n)
Visualization
5
[0]
12
[1]
3
[2]
8
[3]
19
[4]
7
[5]
14
[6]
Complexity Analysis
0255075100nops
O(1)
O(log n)
O(n)
O(n log n)
O(n²)
Input size n =50
OperationComplexityAt n=50Growth
AccessO(1)1
SearchO(n)50
InsertO(n)50
DeleteO(n)50
Space:O(n)auxiliary memory
Index-based access is instant. Insertions and deletions cost O(n) because every element after the target must shift.
Pseudocode
// Access by index — O(1)
arr[i]
// Linear Search — O(n)
for i in 0..n:
if arr[i] == target: return i
// Insert at end — O(1) amortized
arr.push(val)
// Insert at index — O(n) shifts
arr.splice(idx, 0, val)
// Delete at index — O(n) shifts
arr.splice(idx, 1)