资源 · 指南或文章
Fisher–Yates shuffle
用通俗语言描述 Fisher-Yates 洗牌算法,用于原地生成无偏的随机排列。
审核日期
打开原站: Fisher–Yates shuffle (在新标签页中打开原网站)添加到路线图
把这个资源放进你正在跟进的路线图。它会作为你自己的补充资源显示;路线图的步骤不会改变,也不计入你已记录的步骤。
来源内容语言:英语
The Fisher–Yates shuffle is an algorithm for generating a random permutation of a finite sequence—in plain terms, the algorithm shuffles the sequence. The algorithm effectively puts all the elements into a hat; it continually determines the next element by randomly drawing an element from the hat until no elements remain. The algorithm produces an unbiased permutation: every permutation is equally likely. The modern version of the algorithm is efficient: it takes time proportional to the number of items being shuffled and shuffles them in place.
PrepKit 概览
本概览由 PrepKit 编辑根据源代码仓库撰写并审核,并非资源本身的文字。
- 适合人群
- 来源未说明适用级别
- 形式
- 参考资料
涵盖内容
- 用“从帽子里抽签”的直觉解释如何挑选下一个元素。
- 声称输出无偏、时间与元素个数成线性关系,并且原地操作。
使用建议
这是 PrepKit 的学习建议,并非来源的说法。
编写原地洗牌函数,对 [1, 2, 3] 洗牌多次,检查六种排列出现的频率是否大致相同。
范围与局限
只有一段文字:没有步骤列表、伪代码或常见错误。唯一的参考资料是维基百科。
获取方式与形式
GitHub 上的免费英文 README;trekhleb/javascript-algorithms,MIT 许可。
PrepKit 于 2026年10月2日 审核。 资源来源提交: 85293e3e2b88
本概览的依据
- src/algorithms/sets/fisher-yates/README.md
收录此条目的页面
订阅 PrepKit 通讯
可选。使用 PrepKit 并不需要订阅。