1. 程式人生 > >python資料結構與演算法-單向迴圈連結串列

python資料結構與演算法-單向迴圈連結串列

單向迴圈列表與單鏈表的區別是:讓原有單鏈表的尾節點的指標區指向頭結點

單向迴圈連結串列的初始構造:

 

class SingleLinkList(object):
    #單向迴圈連結串列
    def __init__(self,node=None):
       
        self.__head = node
        if node:                 #起始節點 私有屬性,外部無法訪問
            node.next=node            #迴圈連結串列,指向自身