Which standard-library types implement an array-list and a linked list in Java and Python?
Java: java.util.ArrayList (array-list) and java.util.LinkedList (linked list). Python: the built-in list is an array-list, and collections.deque plays the linked-list role, with fast access only at its two ends.
| Array-list | Linked list | |
|---|---|---|
| Java | java.util.ArrayList |
java.util.LinkedList (doubly-linked) |
| Python | list |
collections.deque |
The Python pairing surprises people. Python's list is not a linked list despite the name: it is a dynamic array, so lst[i] is $O(1)$ but lst.insert(0, x) and lst.pop(0) shift everything and are $O(n)$. When you need cheap operations at the front, collections.deque gives $O(1)$ appendleft/popleft as well as append/pop.
deque is not a general-purpose linked list, though. It is built for access at the ends; indexing into its middle is slow, and it has no "insert after this node" operation. That is exactly the double-ended queue interface, which is why it doubles as Python's go-to queue and deque type.
Go deeper:
collections.deque — the $O(1)$ operations at both ends, and why indexing the middle is slow.
java.util.LinkedList — the doubly-linked list implementing both
ListandDeque.