"Newbie" questions - "unique" sorting ?

Cousin Stanley CousinStanley at hotmail.com
Thu Jun 26 19:16:16 CEST 2003


| Not only does it create a new keys list (D.keys()),
| but it searches linearly through it (x in L)!
|
| Those are two separate O(n) operations,
| whereas D.has_key is effectively O(1).

Erik ...

Incurring the 7 hour wrath of  2 * O( n )  in this test
was certainly informative for me, but not much fun ....

I could have interrupted the process,
but knowing it ran to completion for smaller inputs,
I was curious as to the eventual outcome ....

Since n increases as keys are added to the dictionary,
2 * O( n ) for the current pass should also be a bit slower
than for the previous one making it even slower and slower
as more and more keys are added ....

Thanks for the info ....

-- 
Cousin Stanley
Human Being
Phoenix, Arizona






More information about the Python-list mailing list