V2EX  ›  英汉词典
Enqueued related words: Range Sum Query, Difference Array

Prefix Sum

释义 Definition

prefix sum(前缀和/前缀累加和):在数组或序列中,指从开头开始到某个位置为止的元素累计总和;常用于把区间求和等问题从“逐项相加”优化为“用两次相减快速得到结果”。(在算法与数据结构语境中最常见;有时也称 cumulative sum。)

发音 Pronunciation (IPA)

/ˈpriːfɪks sʌm/

例句 Examples

We can use a prefix sum to get the total quickly.
我们可以用前缀和来快速得到总和。

After building the prefix sum array, the sum from index l to r can be computed in O(1) time as pre[r] - pre[l-1].
构建前缀和数组后,从下标 lr 的区间和可以用 pre[r] - pre[l-1] 在 O(1) 时间内计算出来。

词源 Etymology

prefix 来自拉丁语 *prae-*(“在前”)+ fixus(“固定的”),本义是“加在词前的成分”;sum 来自拉丁语 summa(“总量、总和”)。合起来 prefix sum 字面意思就是“前面部分的总和”,在计算机算法中被用来表示“从起点累加到当前位置的和”。

相关词 Related Words

文献与作品 Literary / Notable Works

  • Introduction to Algorithms(CLRS,《算法导论》)——在前缀和、前缀计算与相关区间查询思想中常见类似表述与用法
  • Competitive Programming(Steven Halim 等)——常以 prefix sums 作为基础技巧用于区间和、频次统计与优化
  • The Algorithm Design Manual(Steven S. Skiena,《算法设计手册》)——在数组预处理、区间查询等讨论中常涉及前缀和思想
  • Algorithms(Robert Sedgewick & Kevin Wayne)——在数组与累加/预处理相关章节中常出现前缀累加的应用
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   4112 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 18ms · UTC 05:20 · PVG 13:20 · LAX 22:20 · JFK 01:20
♥ Do have faith in what you're doing.