Sort one sequence by O(n) in time and O(1) in space

Sturla Molden sturla.molden at gmail.com
Mon Feb 10 10:03:25 EST 2014


Chris Angelico <rosuav at gmail.com> wrote:

> That's assuming it really is a sort operation. The problem description
> isn't entirely clear on this point, but if it's actually a zip, then
> it can definitely be done in O(n).

Ah, I didn't read it carefully enough. :-)

Granted, a zip can be done in O(n) time and O(1) memory using a generator,
which by the way is what itertools.izip does.

Sturla




More information about the Python-list mailing list