12 Feb
2009
12 Feb
'09
4:12 p.m.
On Thu, Feb 12, 2009 at 2:59 PM, Ralf W. Grosse-Kunstleve
* insertion and lookup times are O(1), not O(n log n).
Sorry, I was thinking the .add() is happening inside a loop with N iterations, with N also being the eventual size of the set. Is O(N log N) correct then?
http://en.wikipedia.org/wiki/Big_O_notation says:
O(log N) example: finding an item in a sorted array with a binary search.
Isn't that what set is doing?
Python's set uses an unsorted hash table internally and is thus O(1), not O(N). Cheers, Chris -- Follow the path of the Iguana... http://rebertia.com