Programming pearls: a sample of brilliance
暂无分享,去创建一个
(It is important that no number appear twice; holding more than one ace of spades can jeopardize a cardplayer’s health.) Random samples also arise in applications such as simulation, program testing, and statistics. The first section of this column reviews several standard algorithms for random sampling. The next section describes an elegant new algorithm by Floyd. The third section describes how Floyd extends his algorithm to generate random permutations.
[1] Robert W. Floyd,et al. Nondeterministic Algorithms , 1967, JACM.