Generate sample of 1,000,000 random permutations

前端 未结 4 1788
无人及你
无人及你 2020-12-07 03:46

I am working with large number of integer permutations. The number of elements in each permutation is K. The element size is 1 byte. I need to generate N unique random permu

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 03:59

    Heres one way of doing it.

    1) generate first N permutations and store them on the disk.

    2) then run a randomize algorithm on the permutations.

    You can optimize using Divide and Conquer , by picking only a first X elements from the disk and then randomizing it, and the next X elements in the next iteration, and so on... and then merge the results.

    You probably don't need the disk here.

提交回复
热议问题