Is there a predefined linked list library in Python?

I know that in C ++ it already exists #include <list> Now I'm curious to know if this exists in python.

+7
python linked-list singly-linked-list
source share
2 answers

You can also look at the llist python packege, which provides some useful features that deque does not support. This package has not only a double link structure, but also one linked list structure. IMHO, one of the biggest advantages of this package is the ability to maintain links to list items.

+6
source share

Collections.deque seems to be a doubly linked list library in Python. According to the documentation, it should have approximately O (1) value when adding or popping out of the head or tail, and also O (n) for regular inserts (which is what is expected from the linked list).

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

Source: stack overflow

+1
source share

All Articles