AlgoScope

Array Delete

Close the gap by shifting everything after the slot one place left.

Array algorithms and techniques, algorithm, beginner
Array of 5 values. Deleting 1 at index 1 requires shifting 3 values left.5011422384i
Array of 5 values. Deleting 1 at index 1 requires shifting 3 values left.5011422384i

Array: Delete index 1

Start, step 1 of 6

Delete index 1. Removing 1 leaves a gap that everything to the right must close.

How array works

Cost

Best
O(1)
Average
O(n)
Worst
O(n)
Space
O(1)

Best case is deletion at the end.

Before this

Taught by the same lesson

Array covers these too, in the same run.