Array Flashcards
1
Q
Accessing a value at a given index?
A
O(1)
2
Q
Updating a value at a given index?
A
O(1)
3
Q
Inserting a value at the beginning?
A
O(N)
4
Q
Inserting a value in the middle?
A
O(N)
5
Q
Inserting a value at the end? (2)
A
Dynamic Arrays: Amortised O(1)
Static Arrays: O(N)
6
Q
Removing a value at the beginning?
A
O(N)
7
Q
Removing a value in the middle?
A
O(N)
8
Q
Removing a value at the end?
A
O(1)
9
Q
Copying the array?
A
O(N)
10
Q
Initialising an array?
A
O(N)
11
Q
Traverse an array?
A
O(N)
12
Q
What are the 4 operations of an array that are constant time?
A
- Accessing
- Updating
- Removing at end
- Inserting at end (dynamic array only)
13
Q
What are the two possible complexities of an arrays operations?
A
- O(1)
2. O(N)
14
Q
.map?
A
O(N)
15
Q
.reduce?
A
O(N)