Linked List Flashcards
1
Q
Accessing the head?
A
O(1)
2
Q
Accessing the tail? (2)
A
- O(N) without a reference to the tail.
2. O(1) with a reference to the tail.
3
Q
Accessing a middle node?
A
O(N)
4
Q
Inserting or Removing the head?
A
O(1)
5
Q
Inserting or Removing the tail? (2)
A
- O(N) to access + O(1) to insert/remove. Without a stored tail reference.
- O(1) to insert/remove. With a stored tail reference.
6
Q
Inserting or Removing a middle node?
A
- O(N). O(N) to access + O(1) to insert/remove.
7
Q
Searching for a value?
A
O(N)