LinkedLists Flashcards

1
Q

Inserting a Node in the middle

A

(1) Initiaize new node (2) point newNode.next to desiredPrev.next (3) point desiredPrev.next to newNode ; O(1)

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

Inserting a Node at the head

A

(1) Initiaize new node (2) point newNode.next to head (3) point head to newNode ; O(1)

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

Inserting a Node at the tail

A

(1) Initialize new node (2) point tail.next to newNode or find first Node with .next == null [last node] (3) point taill to new Node ; O(1) or O(n) if have to search for tail

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

Deleting a Node in the middle

A

(1) find prev of deleteNode (2) point prev.next to deleteNode ; O (N) to search for prev

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

Deleting a Node at the head

A

(1) point head to head.next ; O(1)

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

Deleting a Node at the tail

A

(1) find prev of tailNode (2) point prev.next to null ; O(N) for search for prev

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