Re: random shuffles

2006-07-26 Thread Boris Borcic
I wrote : > > ...in this sense, it is clear that quicksort for instance is optimal* > > It is easy to see, when you detail this algorithm, that never during its > run is the result of a comparison it makes, preordained by comparisons > already made; iow : it doesn't make superfluous or redundan

Re: random shuffles

2006-07-24 Thread Boris Borcic
Paul Rubin wrote: > Boris Borcic <[EMAIL PROTECTED]> writes: >> To be more convincing... assume the algorithm is optimal and calls > > That assumption is not even slightly realistic. Real-world sorting > algorithms almost never do a precisely minimal amount of comparison. 'optimal' or 'minimal a

Re: random shuffles

2006-07-24 Thread Ben Sizer
Ross Ridge wrote: > David G. Wonnacott wrote: > > Couldn't we easily get an n*log(n) shuffle... > > Why are you trying to get an O(n*log(n)) shuffle when an O(n) shuffle > algorithim is well known and implemented in Python as random.shuffle()? I think David is referring to this: "don't you still n

Re: random shuffles

2006-07-22 Thread Ross Ridge
David G. Wonnacott wrote: > Couldn't we easily get an n*log(n) shuffle... Why are you trying to get an O(n*log(n)) shuffle when an O(n) shuffle algorithim is well known and implemented in Python as random.shuffle()? Ross Ridge -- http://mail.python.org/mailman/listinfo/

Re: random shuffles

2006-07-22 Thread danielx
David G. Wonnacott wrote: > From: "danielx" <[EMAIL PROTECTED]> >Date: 22 Jul 2006 01:43:30 -0700 > >Boris Borcic wrote: >> does >> >> x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) >> >> pick a random shuffle of x with uniform distribution ? > > ... > >Let e be

Re: random shuffles

2006-07-22 Thread David G. Wonnacott
From: "danielx" <[EMAIL PROTECTED]> Date: 22 Jul 2006 01:43:30 -0700 Boris Borcic wrote: > does > > x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) > > pick a random shuffle of x with uniform distribution ? ... Let e be the element which was in the first position t

Re: random shuffles

2006-07-22 Thread danielx
Boris Borcic wrote: > does > > x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) > > pick a random shuffle of x with uniform distribution ? > > Intuitively, assuming list.sort() does a minimal number of comparisons to > achieve the sort, I'd say the answer is yes. But I don't feel quite > confor

Re: random shuffles

2006-07-21 Thread bryanjugglercryptographer
Boris Borcic wrote: > does > > x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) > > pick a random shuffle of x with uniform distribution ? > > Intuitively, assuming list.sort() does a minimal number of comparisons to > achieve the sort, I'd say the answer is yes. You would be mistaken (except

Re: random shuffles

2006-07-21 Thread Raymond Hettinger
Boris Borcic wrote: > does > > x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) > > pick a random shuffle of x with uniform distribution ? > > Intuitively, assuming list.sort() does a minimal number of comparisons to > achieve the sort, I'd say the answer is yes. But I don't feel quite > confo

Re: random shuffles

2006-07-21 Thread Paul Rubin
Boris Borcic <[EMAIL PROTECTED]> writes: > To be more convincing... assume the algorithm is optimal and calls That assumption is not even slightly realistic. Real-world sorting algorithms almost never do a precisely minimal amount of comparison. -- http://mail.python.org/mailman/listinfo/python-

Re: random shuffles

2006-07-21 Thread Boris Borcic
Boris Borcic wrote: > Paul Rubin wrote: >> Boris Borcic <[EMAIL PROTECTED]> writes: >>> x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) >>> pick a random shuffle of x with uniform distribution ? >> >> You really can't assume anything like that. Sorting assumes an order >> relation on the items

Re: random shuffles

2006-07-21 Thread Boris Borcic
Boris Borcic wrote: > Paul Rubin wrote: >> Boris Borcic <[EMAIL PROTECTED]> writes: >>> x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) >>> pick a random shuffle of x with uniform distribution ? >> >> You really can't assume anything like that. Sorting assumes an order >> relation on the items

Re: random shuffles

2006-07-21 Thread Boris Borcic
Thanks for these details. BB Tim Peters wrote: > [ Boris Borcic] >> x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) >> >> pick a random shuffle of x with uniform distribution ? > > Say len(x) == N. With Python's current sort, the conjecture is true > if and only if N <= 2. > >> Intuitively,

Re: random shuffles

2006-07-21 Thread Boris Borcic
Paul Rubin wrote: > Boris Borcic <[EMAIL PROTECTED]> writes: >> x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) >> pick a random shuffle of x with uniform distribution ? > > You really can't assume anything like that. Sorting assumes an order > relation on the items being sorted, which means

Re: random shuffles

2006-07-21 Thread Paul Rubin
Boris Borcic <[EMAIL PROTECTED]> writes: > x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) > pick a random shuffle of x with uniform distribution ? You really can't assume anything like that. Sorting assumes an order relation on the items being sorted, which means if a < b and b < c, then a <

Re: random shuffles

2006-07-21 Thread Tim Peters
[ Boris Borcic] > x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) > > pick a random shuffle of x with uniform distribution ? Say len(x) == N. With Python's current sort, the conjecture is true if and only if N <= 2. > Intuitively, assuming list.sort() does a minimal number of comparisons to

Re: random shuffles

2006-07-21 Thread Iain King
Dustan wrote: > Boris Borcic wrote: > > does > > > > x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) > > > > pick a random shuffle of x with uniform distribution ? > > > > Intuitively, assuming list.sort() does a minimal number of comparisons to > > achieve the sort, I'd say the answer is yes.

Re: random shuffles

2006-07-21 Thread Dustan
Boris Borcic wrote: > does > > x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) > > pick a random shuffle of x with uniform distribution ? > > Intuitively, assuming list.sort() does a minimal number of comparisons to > achieve the sort, I'd say the answer is yes. But I don't feel quite > confo

Re: random shuffles

2006-07-21 Thread Peter Otten
Boris Borcic wrote: > does > > x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) > > pick a random shuffle of x with uniform distribution ? > > Intuitively, assuming list.sort() does a minimal number of comparisons to > achieve the sort, I'd say the answer is yes. But I don't feel quite > con

random shuffles

2006-07-21 Thread Boris Borcic
does x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) pick a random shuffle of x with uniform distribution ? Intuitively, assuming list.sort() does a minimal number of comparisons to achieve the sort, I'd say the answer is yes. But I don't feel quite confortable with the intuition... can an