Time complexity of operations in SortedList - Python

5.1k Views Asked by At

What is the time complexity of operations in SortedList implementation of sortedcontainers module? As I understand, the underlying data structure is an array list. So does insertion takes O(n) time since the index can be found in O(logn) and then insert the element at the correct location is O(n)? Similarly, popping an element from an index must be O(n) as well.

1

There are 1 best solutions below

0
On

Insert, remove, get index, bisect right and left, find element inside list, are all log(n) operations. Its similar to treeset and multiset in java and c++, implemented with AVL tree or red black tree.