Probability of Outcomes in Merge Shuffle

  • Context: Graduate 
  • Thread starter Thread starter ardentra
  • Start date Start date
  • Tags Tags
    Probability
Click For Summary
SUMMARY

The discussion focuses on the probability outcomes of the Merge Shuffle algorithm, which operates similarly to Merge Sort but incorporates a 50% chance of selecting elements from either of the two lists during the merge process. The user seeks to determine the probability that performing a Merge Shuffle on a unique input list results in the same list. The user proposes a formula for calculating the probability of an element's position in the target list based on its position in the original list and the number of elements remaining. The challenge lies in analyzing cases where the length of the input list is not a power of two, complicating the probability calculations.

PREREQUISITES
  • Understanding of Merge Sort algorithm
  • Familiarity with probability theory and combinatorial analysis
  • Knowledge of recursion and recursive formulas
  • Basic programming skills for implementing algorithms
NEXT STEPS
  • Research the mathematical foundations of probability in algorithms
  • Explore combinatorial techniques for analyzing non-power of two scenarios
  • Study recursion formulas and their applications in algorithm analysis
  • Implement Merge Shuffle in a programming language to test various input scenarios
USEFUL FOR

Mathematicians, computer scientists, algorithm developers, and anyone interested in the probabilistic analysis of sorting algorithms.

ardentra
Messages
1
Reaction score
0
So I've been banging my head on this problem for a few days and haven't gotten very far, hoping someone has some insights. I know this sort of reads like a homework problem, but this problem is the result of personal investigations and does not come from an assignment.

So for those of you who don't know, Merge Sort is an algorithm that works by taking a list of elements to be sorted, L, and splitting L into halves L1 and L2, then splitting those halves, repeatedly until reaching a set of lists of length 1. Then the lists are recombined with correct ordering until once again arriving at one list, which is now sorted. Lists are not sets: order matters, and in this case you can only add items onto the front of lists.

So say you had the list of numbers 3,9,8,0,2,1,5,7,4,6. Performing Merge Sort would look like this(I removed commas for convenience):

3980215746

39802 15746

39 802 15 746

3 9 8 02 1 5 7 46

3 9 8 0 2 1 5 7 4 6

39 8 02 15 7 46

39 028 15 467

02389 14567

0123456789

During the merge steps, items are selected one at a time from the left side of both L1 and L2, compared to one another, and the item with the smaller value is added to the new list. This step is repeated until the lists have been combined.
So a single merge step would operate like this for lists L1 = 2,3 and L2 = 1,4:

Compare 1 and 2
Add 1 to the recombined list
Compare 2 and 4
Add 2 to the recombined list
Compare 3 and 4
Add 3 to the recombined list
Add 4 to the recombined list


So that is Merge Sort. Merge Shuffle works the same way, except that during the recombining stage, there is a 50% chance of a number being taken from L1 and a 50% chance of a number being taken from L2 for addition to the recombined list.
So combining lists L1 = 1,2 and L2 = 3,4 might operate like this:

Select 1 or 3
Add 3 to the recombined list
Select 1 or 4
Add 1 to the recombined list
Select 2 or 4
Add 4 to the recombined list
Add 2 to the recombined list

Which would create the newly shuffled list L = 3142.

I am fairly sure that at a single add step during a merge, the probability of an element at position e in list E = E1... ...En of length n ending up in position t of the target list T = T1, T2... where x positions in T have already been filled and d = t - x is equal to:

if e > d then probability = 0
if e + o < d then probability = 0
otherwise probability = .5d

Where o is the number of items remaining in the other list being merged.

So this is the question I want to solve: Given input list I of length n, and I containing no repeated items, what is the probability that performing Merge Shuffle on I produces I as the result?

And more generally, given input list I of length n, and I containing no repeated items, what is the probability of producing the given result LI?
 
Last edited:
Physics news on Phys.org
If n is a power of 2, this looks easy to analyze.
If n is not, that looks ugly - you have to keep track of all combinations of k with k+1 elements somewhere. Let f(I) be the result of a merge shuffle. I think f(I)=I can be studied with some casework (look at n=2, n=3, n=4, n=5, ..., try to find a recursion formula), but I don't know how to get the more general result.
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
5K