Linked Lists Flashcards

1
Q

What is the algorithm for searching a linked list? And time complexity?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the algorithm for inserting a node after a node? What is the time complexity?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Deleting after node in linked list and time complexity

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Time complexity of delete (unordered singly linked list)

A

O(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Time complexity of find (unordered singly linked list)

A

O(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Time complexity of delete (ordered singly linked list)

A

O(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Time complexity of find (unordered singly linked list)

A

O(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Time complexity of add (unordered singly linked list)

A

O(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Time complexity of delete (unordered singly linked list)

A

O(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Time complexity of find (ordered singly linked list)

A

O(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Time complexity of add (ordered singly linked list)

A

O(n) unless I have a pointer to the tail, then O(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Time complexity of delete (ordered singly linked list)

A

O(n), unless I want to delete after a node then O(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Are linked lists cache friendly?

A

Unlike arrays where items are always located next to each other in computer memory, linked list nodes can be scatterd all over.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you use fast and slow runners to find linked list cycles?

A
  • Every time slow runner moves 1 node, fast runner moves 2 nodes
  • When slow runner is the same node as fast runner we’ve found a cycle
  • Otherwise fast will hit the end of the linked list
How well did you know this?
1
Not at all
2
3
4
5
Perfectly