Skip to main content

List

OperationAverage CaseAmortized Worst Case
CopyO(n)O(n)
Append[1]O(1)O(1)
Pop lastO(1)O(1)
Pop intermediate[2]O(n)O(n)
InsertO(n)O(n)
Get ItemO(1)O(1)
Set ItemO(1)O(1)
Delete ItemO(n)O(n)
IterationO(n)O(n)
Get SliceO(k)O(k)
Del SliceO(n)O(n)
Set SliceO(k+n)O(k+n)
Extend[1]O(k)O(k)
SortO(n log n)O(n log n)
MultiplyO(nk)O(nk)
x in sO(n)
min(s), max(s)O(n)
Get LengthO(1)O(1)

Collections.deque

OperationAverage CaseAmortized Worst Case
CopyO(n)O(n)
appendO(1)O(1)
appendleftO(1)O(1)
popO(1)O(1)
popleftO(1)O(1)
extendO(k)O(k)
extendleftO(k)O(k)
rotateO(k)O(k)
removeO(n)O(n)
Get LengthO(1)O(1)

Set

OperationAverage caseWorst Case
x in sO(1)O(n)
Union s/tO(len(s)+len(t))
Intersection s&tO(min(len(s), len(t)))O(len(s) * len(t))
Multiple intersection s1&s2&..&sn(n-1)*O(l) where l is max(len(s1),..,len(sn))
Difference s-tO(len(s))
s.difference_update(t)O(len(t))
Symmetric Difference s^tO(len(s))O(len(s) * len(t))
s.symmetric_difference_update(t)O(len(t))O(len(t) * len(s))

Dict

OperationAverage CaseAmortized Worst Case
k in dO(1)O(n)
Copy[3]O(n)O(n)
Get ItemO(1)O(n)
Set Item[1]O(1)O(n)
Delete ItemO(1)O(n)
Iteration[3]O(n)O(n)