What would be a good example of a "linked list" in python?

Viewed 40

I am trying to teach myself programming and have just encountered the concept of arrays vs. linked lists. I would imagine list() and np.array() all are considered to be arrays. I have heard that the collections package has a object type deque that is a linked list. Are there other linked lists in Python? Would a Python dictionary, dict(), be a linked list or an array?

Thanks!

1 Answers

I would imagine list() and np.array() all are considered to be arrays.

Correct.

I have heard that the collections package has a object type deque that is a linked list.

Mostly correct. It is specifically a linked list of arrays, to reduce memory overhead. See here.

Are there other linked lists in Python?

I don't think there are in Python core, but I could be wrong. It is trivial to make one, though one would typically never do it.

Would a Python dictionary, dict(), be a linked list or an array?

Neither. It is a hash table with open addressing.

Related