Linked List 链表
Prerequisite
* 同样是线性结构, **Array是物理连续的**, Linked List 是由Pointer连起来的,**不一定是物理连续的**!
* 链表的题目往往算不上“算法性”题,只是一种模拟操作的题,考察的重点在于bug free,是否对写代码有熟练度!
Key Point
- 1 When you want to de-reference a List Node, make sure it is not a NULL Pointer.
- 任何使用用"."这个符号的时候,一定要注意判断前面的Reference是否为空!!!
- 2 Never ever lost the control of the head pointer of the Linked List.
- 经常需要缓存nxt指针或者prev指针都是因为当你改变链表结构的时候很容易丢失之前或者之后的信息!
Tips
DummyNode
- Why or When should we use a dummy Node?
- When we want to append new elements to an initially empty linkedlist, we do not have an initial head node. In this case, we can new a dummy node to act as a head node.
- 链表的结构发生变化
Two or More Pointers
- We usually use many pointer to manipulate the node of the linked list