Array Visualizer

Explore array indexing, insertion, deletion, search, and reserved capacity through responsive 2D and memory-shelf 3D visualizations.

Current status: Ready

Contiguous memory lab

Array Visualizer

Watch values shift between fixed memory slots, inspect constant-time access, and compare linear and binary search.

Operation console

Value selects data; index selects a memory slot.

Ready

Inputs

Insert without an index appends. Delete accepts a value, an index, or both.

Array operations

Algorithms

2D memory strip

Index → value → address

left / iright / jmid
slot[0]
4
Index 0 · Value 4 · Address 0x100
0x100
slot[1]
4
Index 1 · Value 4 · Address 0x104
0x104
slot[2]
6
Index 2 · Value 6 · Address 0x108
0x108
slot[3]
12
Index 3 · Value 12 · Address 0x10C
0x10C
slot[4]
11
Index 4 · Value 11 · Address 0x110
0x110
slot[5]
5
Index 5 · Value 5 · Address 0x114
0x114
slot[6]
2
Index 6 · Value 2 · Address 0x118
0x118
slot[7]
11
Index 7 · Value 11 · Address 0x11C
0x11C
slot[8]
6
Index 8 · Value 6 · Address 0x120
0x120
slot[9]
8
Index 9 · Value 8 · Address 0x124
0x124
Every cell has the same width because array elements occupy equal-sized slots. Adjacent addresses differ by four bytes in this teaching model.

Quick Sort Live View

4
4
6
12
11
5
2
11
6
8

Traversal Result

Search Result

Perform a search to see results here

What is an Array?

An Array is a linear data structure that collects elements of the same data type and stores them in contiguous and adjacent memory locations. It is one of the most fundamental and widely used data structures in computer science.

Time Complexity

  • Access (by Index)O(1)
  • Search (Linear)O(n)
  • Search (Binary, Sorted)O(log n)
  • Insertion (at end, dynamic)O(1)*
  • Insertion/Deletion (at index)O(n)

* Amortized time complexity for dynamic arrays.

Static vs. Dynamic Arrays

  • Static Arrays: Fixed size determined at compile time. Fast and simple, but inflexible (e.g., C-style arrays).
  • Dynamic Arrays: Automatically resize when full. Flexible but have slight overhead during resizing (e.g., Python Lists, Java ArrayList, C++ Vectors).

Concept guide

Review the mental model, tradeoffs, and practical use cases after you experiment.

Array Complete Info Card

Contiguous MemoryRandom Access

Arrays store elements in contiguous memory locations, enabling efficient index-based access but costly insertions/deletions in the middle. They are the most fundamental data structure in programming.

Time Complexities

Access by Index

Direct memory addressing

O(1)

Search (Unsorted)

Linear search required

O(n)

Search (Sorted)

Binary search possible

O(log n)

Insertion at End

Amortized constant time

O(1)*

Insertion at Start

Requires shifting all elements

O(n)

Deletion at End

No shifting needed

O(1)

Deletion at Start

Requires shifting all elements

O(n)

Update by Index

Direct memory access

O(1)

Common Operations

Traversal

for (let i = 0; i < arr.length; i++)

Mapping

arr.map(x => x * 2)

Filtering

arr.filter(x => x > 5)

Reduction

arr.reduce((sum, x) => sum + x, 0)

Sorting

arr.sort((a, b) => a - b)

Reversal

arr.reverse()

Array Types

Static Array

Fixed size, allocated at compile time

Dynamic Array

Grows/shrinks as needed (like JavaScript arrays)

Multidimensional

Arrays of arrays (matrix, 2D/3D)

Jagged Array

Sub-arrays of different lengths

Advantages

  • Fast access by index (random access)
  • Memory efficient (no overhead per element)
  • Cache friendly (contiguous memory)

Limitations

  • Fixed size for static arrays
  • Costly insertions/deletions in middle
  • Wasted space if allocated too large
Pro Tip: Use arrays when you need frequent random access and know the maximum size in advance.
O(1) accessMemory efficientFixed size