forked from itcharge/LeetCode-Py
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
## 1. 树状数组简介 | ||
|
||
### 1.1 树状数组的定义 | ||
|
||
> **树状数组(Binary Indexed Tree)**:也因其发明者命名为 Fenwick 树,最早由 Peter M. Fenwick 于 1994 年以 A New Data Structure for Cumulative Frequency Tables 为题发表在 SOFTWARE PRACTICE AND EXPERIENCE。其初衷是解决数据压缩里的累积频率(Cumulative Frequency)的计算问题,现多用于高效计算数列的前缀和, 区间和。它可以以 $O(logn)$ 的时间得到任意前缀 $\sum_{i=1}^{j} A[i], 1 \le j \le N$,并同时支持在 $O(logn)$ 时间内支持动态单点值的修改。空间复杂度为 $O(n)$。 | ||
### 1.2 树状数组的原理 | ||
|
||
## 2. 树状数组的基本操作 | ||
|
||
### 2.1 树状数组的建立 | ||
|
||
### 2.2 树状数组的修改 | ||
|
||
### 2.3 树状数组的求和 | ||
|
||
## 4. 树状数组的常见题型 | ||
|
||
### 4.1 单点更新 + 区间求值 | ||
|
||
### 4.2 区间更新 + 单点求值 | ||
|
||
### 4.3 求逆序对数 | ||
|
||
## 参考资料 | ||
|
||
- 【书籍】ACM-ICPC 程序设计系列 - 算法设计与实现 - 陈宇 吴昊 主编 | ||
- 【书籍】算法训练营 陈小玉 著 | ||
- 【博文】[聊聊树状数组 Binary Indexed Tree - halfrost](https://halfrost.com/binary_indexed_tree/) | ||
- 【博文】[树状数组学习笔记 - AcWing](https://www.acwing.com/blog/content/80/) | ||
|