MergeShuffle: A Very Fast, Parallel Random Permutation Algorithm

Axel Bacher, Olivier Bodini, Alexandros Hollender, Jérémie Lumbroso
8/13/2015
cs.DScs.DM

Official code: axel-bacher/mergeshuffle (48 stars, last commit 2015-11-10).

Abstract

This article introduces an algorithm, MergeShuffle, which is an extremely efficient algorithm to generate random permutations (or to randomly permute an existing array). It is easy to implement, runs in $n\log_2 n + O(1)$ time, is in-place, uses $n\log_2 n + Θ(n)$ random bits, and can be parallelized accross any number of processes, in a shared-memory PRAM model. Finally, our preliminary simulations using OpenMP suggest it is more efficient than the Rao-Sandelius algorithm, one of the fastest existing random permutation algorithms. We also show how it is possible to further reduce the number of random bits consumed, by introducing a second algorithm BalancedShuffle, a variant of the Rao-Sandelius algorithm which is more conservative in the way it recursively partitions arrays to be shuffled. While this algorithm is of lesser practical interest, we believe it may be of theoretical value. Our full code is available at: https://github.com/axel-bacher/mergeshuffle

View on arXivView PDF

Code Implementations(1)

484C, ShellAug 11, 201510 years ago

Similar Papers

Cite this paper

@article{bacher2015mergeshuffle,
  title  = {MergeShuffle: A Very Fast, Parallel Random Permutation Algorithm},
  author = {Axel Bacher and Olivier Bodini and Alexandros Hollender and Jérémie Lumbroso},
  year   = {2015},
  eprint = {1508.03167},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/1508.03167}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/1508.03167.svg)](https://codeofpaper.com/paper/1508.03167)

Discussion