---
title: "Discussion on \"树状数组（ Binary Indexed Tree）\" | Hashnode"
description: "Discussion on \"树状数组（ Binary Indexed Tree）\". 树状数组（Fenwick Tree / Binary Indexed Tree）这个东西。这玩意儿听起来挺唬人，但本质上就是个用数组模拟树形结构的工具，专门用来解决一类问题：频繁的单点更新和区间查询。如果我们用普通数组，更新是 O(1)，但查区间和就是 O(N)；用前缀和数组，查区间和是 O(1)，但你更新一个点，后面所有的前缀和都得改，又是 O(N)。两边都不讨好。树状数组就把这两个操作都干到了 O(logN)，一下就平衡了。\n废话不多说，咱们从题入手，看看这东西到底怎么用，思路是怎么一步步升..."
url: "https://hashnode.com/posts/binary-indexed-tree/68e11f128ab625b5566341e4"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [树状数组（ Binary Indexed Tree）](https://xiaoh.hashnode.dev/binary-indexed-tree?utm_source=hashnode&utm_medium=feed)

树状数组（Fenwick Tree / Binary Indexed Tree）这个东西。这玩意儿听起来挺唬人，但本质上就是个用数组模拟树形结构的工具，专门用来解决一类问题：频繁的单点更新和区间查询。如果我们用普通数组，更新是 O(1)，但查区间和就是 O(N)；用前缀和数组，查区间和是 O(1)，但你更新一个点，后面所有的前缀和都得改，又是 O(N)。两边都不讨好。树状数组就把这两个操作都干到了 O(logN)，一下就平衡了。 废话不多说，咱们从题入手，看看这东西到底怎么用，思路是怎么一步步升...

Oct 4, 2025 · 10 min read · xiaoh.hashnode.dev  
Read the article

-   [#5qcr54q25pww57ue](https://hashnode.com/tag/5qcr54q25pww57ue)

## Written by

[MrHe](https://hashnode.com/@MrHe)

@MrHe

  
[View profile](https://hashnode.com/@MrHe)

河南科技大学-软件工程

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
