Data structures: Arrays
23 April 2023 (Updated 23 April 2023)
On this page
What is it?
An ordered list of items.
const names = ['Jim', 'Bob', 'Alice']
Big O
- Access: O(1)
- Insertion
- Insertion at the end: O(1)
- Insertion at the beginning: O(n) – We have to re-index all the other elements in the existing array.
- Removal
- Removal at the end: O(1)
- Removal at the beginning: O(n) – We have to re-index all the other elements in the existing array.
- Searching: O(n)
When to use?
- When you need the items to be ordered.
- You need fast insertion and access.
Tagged:
Data structures
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment