Linked List
Contents
Theory
Key points for using linked list
:
- when we are trying to dereference a
ListNode
, we should check if the node isnull
, or we may get anNPE (Null Pointer Exception)
. - We shouldn’t lose the control of
head
node, because if we lost it, we can not get the list’s nodes anymore. In some situations, like if we set a dummy, or trying to reverse a linkedlist, we may change thehead
, so it depends, but still need to be very careful.
Dummy Node: When we can not determine the head of linked list which we need to return, we may use dummy node.
Reverse Linked List
|
|