ITKokka

Array Visualizer

See how array operations work step by step, with a live step log explaining each move.

5
0
3
1
8
2
1
3
9
4

Length: 5 / 10

Current length: 5

Push

O(1)

Add a value to the end. No other elements move.

Step Log

$ Run an operation above to see step-by-step narration here.

Array Operation Complexity

OperationTime ComplexityWhy
Access by indexO(1)Memory address is calculated directly from the index.
Push / Pop (at end)O(1)No other elements need to move.
RemoveO(n)Elements after the index must shift left by one position.
Linear searchO(n)Every element may need to be checked in the worst case.

How to Use

  1. 1

    Pick an operation tag (Push, Search, Update, Remove, Pop, or Clear). Hover a tag to see its complexity and what it does.

  2. 2

    Enter a value or index where needed, then run it. Pop and Clear run immediately since they need no input.

  3. 3

    Watch the boxes animate and read the step log below to see exactly what the array does.

FAQ

What is an array?

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.

Why does removing a value take longer than pushing?

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.

Why is linear search O(n)?

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.

Related

All Data StructuresJSON Visualizer