Time Complexity of OrderedSet() in python [closed]
Asked Answered
S

1

7

I was going through this answer on Stack Overflow. I came to know about existence of OrderedSet in Python. I would like to know how it is implemented internally. Is it similar to hash table implementation of sets?

Also, what is the time complexity of some of the common operations like insert, delete, find, etc.?

Slr answered 27/2, 2018 at 7:58 Comment(3)
Did you read the linked documentation? OrderedSet isn't part of the standard library.Confirmatory
Thanks for the link @jonrsharpe. The link to the implementation was usefulSlr
@Slr then maybe you could answer your own question.Degraded
J
4

From the documentation available here

Implementation based on a doubly linked link and an internal dictionary. This design gives OrderedSet the same big-Oh running times as regular sets including O(1) adds, removes, and lookups as well as O(n) iteration.

There is also a discussion on the topic, see Does Python have an ordered set?

Jedjedd answered 19/12, 2019 at 22:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.