Linked List

Single LinkedList

node<T>:
  val: T
  next?: Node<T>
  • You can't walk backwards.

**Double

node<T>:
  val: T
  next?: Node<T>
  prev?: Node<T>
  • You can walk backwards.

Insertion Current node:

A->B->C->D

When you insert F after A and before B.

A->F
F->B
F<-B
A<-F

Deletion

Current node:

A->B->C->D

When deleting:

B = C.prev
B.next = C.next
D.prev = C.prev
C.prev = C.next = null