Re: How to prove that a random sort algorithm converges?



[James]
Supposed I want to sort four numbers {5, 2, 4, 3}
I randomly select a pair of two numbers at adjacient poisitions, say i
and i+1, and I swap their position if the value at position i is
greater than the value at position i+1 (e.g., 5 > 2 so swap their
positions).

If I do this (random selection and ordering) long enough, I would
expect that the numbers are sorted.

My question is: how do I prove that this algorithm converges?

I'd try proof by induction on the number of inversions. An "inversion" is
an index pair <i, j> where i < j and x_i > x_(i+1). For example, in your
example there are 4 inversions: 5 > 2, 5 > 4, 5 > 3, and 4 > 3. Prove that
a list is sorted if and only if the number of inversions is 0. Prove that
each step in your algorithm either leaves the number of inversions alone
(when the elements at the position picked are already in order) or reduces
the number of inversions by one (when the elements are swapped). Prove that
if the number of inversions is > 0, then there's at least one pair of
_adjacent_ elements out of order.

Put that all together and you've shown that so long as your list is
unsorted, your algorithm will never increase disorder (will never increase
the number of inversions), and that there's at least one pair of adjacent
elements out of order (because the number of inversions is > 0 so long as
the list is unsorted). The rest depends on exactly what you mean by
"converges" ;-) For example, by your meaning is it true that applying your
algorithm to a list with a single pair of adjacent out-of-order elements
converges? If so, the rest should be easy: it converges when the number of
inversions is 1; assume it converges when the number of inversions is n;
under that assumption, show that it converges when the number of inversions
is n+1.


.



Relevant Pages

  • Re: How to prove that a random sort algorithm converges?
    ... The number of transpositions needed is the number of inversions, ... upperbound" for the algorithm is a good point. ... runs forever without any determination that the array has been ... (because the actual swaps will reach the theoretical maximum ...
    (sci.math)
  • Re: How to prove that a random sort algorithm converges?
    ... The number of transpositions needed is the number of inversions, ... why I pushed him toward reasoning about inversions. ... upperbound" for the algorithm is a good point. ...
    (sci.math)
  • Calculate number of (binary) inversions
    ... I'm looking for an algorithm that counts the number of binary ... inversions in thetaor "normal" inversions in nlog. ... A sample for binary inversion: has 4 inversions:, ... programm in Perfect Developer. ...
    (comp.theory)
  • Re: How to prove that a random sort algorithm converges?
    ... I randomly select a pair of two numbers at adjacient poisitions, ... and I swap their position if the value at position i is ... how do I prove that this algorithm converges? ... U.S. Court of Appeals to review three issues ...
    (sci.math)
  • Re: How to prove that a random sort algorithm converges?
    ... I randomly select a pair of two numbers at adjacient poisitions, ... and I swap their position if the value at position i is ... how do I prove that this algorithm converges? ... you could show that after n trials with k numbers that the probability it is ...
    (sci.math)

Quantcast