[prev] 46 [next]

Performance of Set Implementations (cont)

Notes on performance differences ...

Assume O(1) card, because we keep a count of #elems

For sorted array, insert cost is: cost of find + cost to interpolate
Cost = log2n tests + (avg)n/2 moves ⇒ O(n)

Two O(n) costs:  linked list = k.n,  hash table = j.n  but  j≪k (lists are shorter)

If lists are sorted, use merge for and so O(n+m)

Bit-map version restricts range of possible elements to 0..N-1