multiset, map and hash map complexity

map, set, multimap, and multiset These are implemented using a red-black tree, a type of balanced binary search tree. They have the following asymptotic run times: Insertion: O(log n) Lookup: O(log n) Deletion: O(log n) hash_map, hash_set, hash_multimap, and hash_multiset These are implemented using hash tables. They have the following runtimes: Insertion: O(1) expected, O(n) … Read more

What does “O(1) access time” mean? [duplicate]

You’re going to want to read up on Order of complexity. http://en.wikipedia.org/wiki/Big_O_notation In short, O(1) means that it takes a constant time, like 14 nanoseconds, or three minutes no matter the amount of data in the set. O(n) means it takes an amount of time linear with the size of the set, so a set … Read more

Complexity of list.index(x) in Python

It’s O(n), also check out: http://wiki.python.org/moin/TimeComplexity This page documents the time-complexity (aka “Big O” or “Big Oh”) of various operations in current CPython. Other Python implementations (or older or still-under development versions of CPython) may have slightly different performance characteristics. However, it is generally safe to assume that they are not slower by more than … Read more

What’s the time complexity of array.splice() in Google Chrome?

Worst case should be O(n) (copying all n-1 elements to new array). A linked list would be O(1) for a single deletion. For those interested I’ve made this lazily-crafted benchmark. (Please don’t run on Windows XP/Vista). As you can see from this though, it looks fairly constant (i.e. O(1)), so who knows what they’re doing … Read more