Array Insert
Make room by shifting everything after the slot one place right, then write.
Array: Insert 7 at index 2
Index 2 is free. Place 7 there.
Cost
- Best
- O(1)
- Average
- O(n)
- Worst
- O(n)
- Space
- O(1)
Best case is insertion at the end.
Before this
Related
Taught by the same lesson
Array covers these too, in the same run.