Array Visualizer Ready
size 5 capacity 10
  • Current
  • Comparing
  • Found / new
  • Removing
  • Empty slot

Ready

Comparisons 0 Shifts 0
Ready

Keyboard: ← → step · Space play / pause · R reset · Esc exit classroom mode

How it works

Every operation, in plain steps

These are exactly the steps the visualizer animates.

Insert

  1. Check there is free space (size < capacity).
  2. Shift every element from the last one down to the position one step right.
  3. Place the new value in the free slot.
  4. Increase the size by 1.

Delete

  1. Check the array is not empty.
  2. Remove the value at the position.
  3. Shift every element after it one step left to close the gap.
  4. Decrease the size by 1.

Search (linear)

  1. Start at index 0.
  2. Compare each element with the target.
  3. Stop as soon as you find a match.
  4. If you reach the end, the value is not there (-1).

Update

  1. Calculate the address: base + index × element size.
  2. Jump straight to that slot — no searching.
  3. Overwrite the old value with the new one.
Algorithm

Pseudocode

Language-independent steps. The visualizer shows the same logic in C, Python and Java.

1 INSERT(arr, n, pos, value)
2 if n = CAPACITY then report "Overflow" and stop
3 for i ← n − 1 down to pos
4 arr[i + 1] ← arr[i]
5 arr[pos] ← value
6 n ← n + 1
Complexity

How fast is each operation?

n = number of elements. Every operation uses O(1) extra space.

Operation Best Average Worst Speed
Access / Update O(1) O(1) O(1) Instant
Insert O(1) O(n) O(n) Grows with n
Delete O(1) O(n) O(n) Grows with n
Linear Search O(1) O(n) O(n) Grows with n
Traverse O(n) O(n) O(n) Grows with n
Practice

Check your understanding

Answer each question — you will see the explanation straight away.

0 / 4 correct
Question 1

In arr = [10, 20, 30, 40, 50], at which index is the value 30 stored?

Question 2

You insert a value at index 0 of an array holding n elements. How many elements must be shifted?

Question 3

Why can an array read arr[i] in O(1) time?

Question 4

Deleting the LAST element of an array needs how many shifts?

Assessment

Arrays quiz

Test yourself: 5 questions, 70% to pass. Create a free account to take the quiz, save your progress and work towards the certificate.