Singly Linked List

  1. Single head List
  2. head & tail List
  3. head & size List
  4. head, tail & size List
  1. no sentinel
  2. sentinel nodes for head and tail

循环链表(Circular Linked list)

循环链表与双向链表相似,不同的地方在于:在链表的尾部增加一个指向头结点的指针,头结点也增加一个指向尾节点的指针,以及第一个节点指向头节点的指针,从而更方便索引链表元素。

Insertion

  1. insert at head (头插法)Add Two Numbers
  2. insert at tail (尾插法)Add Two Numbers
  3. insert at index

delete

  1. delete at head
  2. delete at tail
  3. delete at index

Helper:

  1. check tail node (getTail)
    在双向链表中,第一个节点的前驱节点不是头结点,而是指向一个空指针。同样的,最后一个节点的后驱指向了一个空指针。

  2. getIndex

  3. getNode

  4. get

results matching ""

    No results matching ""