Is there a linked list predefined library in Python? [closed] Is there a linked list predefined library in Python? [closed] python python

Is there a linked list predefined library in Python? [closed]


You can also take a look at llist python package, which provides some useful features that deque does not. There are not only doubly linked lists, but also single linked lists data structure in that package. IMHO, one of the biggest advantages of this package is the ability to store a reference to the llist elements.


It appears that collections.deque is a doubly-linked-list library in Python. According to the documentation, it should have approximately O(1) cost when appending or popping from the head or the tail, as well as O(n) for regular inserts (which matches what we'd expect from a linked list).

API: http://docs.python.org/2/library/collections.html#collections.deque

Source: https://stackoverflow.com/a/282238/2441252