05-2_ singly linked list

Singly linked list

Also known as singly linked lists single linked list, the list is the most simple form, which each node contains two fields, an information field (field element) and a link field. The link points to the next node in the linked list, and the link field points to the last node is a null value.

  • Table elem elements field used to store specific data.
  • Next link field for the storage of the next node (identified in python)
  • The position of the head node variable p points to the list (the first node), and p departure from any node can be found in the table.

Single-node linked list

class SingleNode(object):
    """单链表的节点"""
    def __init__(self, elem):
        """
        一个节点的初始状态
        """
        self.item = elem
        self.next = None

Guess you like

Origin www.cnblogs.com/nichengshishaonian/p/11576100.html