Written on November 17, 2023
Basic explanation of arrays and various nuances
Definition: Arrays is a data structure that is structured as a contiguous memory spaces for data values.
Action | Time | Space |
---|---|---|
Access | O(1) | O(1) |
Set | O(1) | O(1) |
Traverse/Search | O(n) | O(1) |
Copy | O(n) | O(n) |
Insert | ||
at the beginning | O(n) | O(1) |
at the end | O(1) | O(1) |
somewhere in middle | O(n) | O(1) |
Remove | ||
at the beginning | O(n) | O(1) |
at the end | O(1) | O(1) |
somewhere in middle | O(n) | O(1) |