跳到主要内容

资源 · 指南或文章

Pascal's Triangle

讲解杨辉三角(帕斯卡三角)如何由二项式系数构成,以及如何高效计算其中一行,这一模式常见于组合数学类编程题。

审核日期

打开原站: Pascal's Triangle (在新标签页中打开原网站)

添加到路线图

把这个资源放进你正在跟进的路线图。它会作为你自己的补充资源显示;路线图的步骤不会改变,也不计入你已记录的步骤。

来源内容语言:英语

In mathematics, Pascal's triangle is a triangular array of the binomial coefficients. The rows of Pascal's triangle are conventionally enumerated starting with row n = 0 at the top (the 0th row). The entries in each row are numbered from the left beginning with k = 0 and are usually staggered relative to the numbers in the adjacent rows. The triangle may be constructed in the following manner: In row 0 (the topmost row), there is a unique nonzero entry 1. Each entry of each subsequent row is constructed by adding the number above and to the left with the number above and to the right, treating blank entries as 0. For example, the initial number in the first (or any other) row is 1 (the sum of 0 and 1), whereas the numbers 1 and 3 in the third row are added to produce the number 4 in the fourth row. The entry in the nth row and kth column of Pascal's triangle is denoted . For example, the unique nonzero entry in the topmost row is .

PrepKit 概览

本概览由 PrepKit 编辑根据源代码仓库撰写并审核,并非资源本身的文字。

适合人群
来源未说明适用级别
形式
参考资料

涵盖内容

  • 构造规则:每一项等于其上方两项之和,空位视为 0。
  • 公式部分把各项与二项式系数联系起来。
  • 在 O(n) 时间内计算三角形中的项:每一步用 O(1) 时间由 C(n, i - 1) 推出 C(n, i)。

使用建议

这是 PrepKit 的学习建议,并非来源的说法。

用两种方法生成第 10 行:一是对上一行求和,二是用 C(n, i - 1) 递推,并确认两者一致。

范围与局限

公式以渲染图片的形式出现,页面主要依赖维基百科和 GeeksForGeeks 的链接。没有练习。

获取方式与形式

在 GitHub 上阅读;采用 MIT 许可的 trekhleb/javascript-algorithms 项目中的英文 README。

PrepKit 于 2026年10月2日 审核。 资源来源提交: 85293e3e2b88

本概览的依据
  • src/algorithms/math/pascal-triangle/README.md

收录此条目的页面

订阅 PrepKit 通讯

可选。使用 PrepKit 并不需要订阅。

我们如何处理你的邮箱