Hpw make lists that are easy to sort.
Anton Vredegoor
anton.vredegoor at gmail.com
Wed Mar 28 16:19:01 EDT 2007
Paul Rubin wrote:
> Well there are various hacks one can think of, but is there an actual
> application you have in mind?
Suppose both input lists are sorted. Then the product list is still not
sorted but it's also not completely unsorted. How can I sort the
product? I want to know if it is necessary to compute the complete
product list first in order to sort it. Is it possible to generate the
items in sorted order using only a small stack?
Also, I have a sumfour script that is slow because of sorting. It would
become competitive to the hashing solution if the sorting would be about
ten times faster. If the items could be generated directly in order the
script would also have only a very small memory footprint.
> If you really want the sum of several probability distriutions (in
> this case it's the sum of several copies of the uniform distribution),
> it's the convolution of the distributions being summed. You can do
> that with the fast fourier transform much more efficiently than
> grinding out that cartesian product. But I don't know if that's
> anything like what you're trying to do.
I want the product, but sorted in less time. If Fourier transforms can
help, I want them :-)
A.
More information about the Python-list
mailing list