|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Fenwick tree (Binary Indexed Tree) for prefix queries. More...
#include <bit>#include <cassert>#include <concepts>#include <initializer_list>#include <type_traits>#include <vector>#include <utility>#include <tpl_array.H>#include <tpl_dynList.H>#include <ahFunction.H>#include <ah-errors.H>Go to the source code of this file.
Classes | |
| class | Aleph::Gen_Fenwick_Tree< T, Plus, Minus > |
| Fenwick tree over an arbitrary abelian group. More... | |
| struct | Aleph::Fenwick_Tree< T > |
| Fenwick tree for arithmetic types with find_kth support. More... | |
| class | Aleph::Range_Fenwick_Tree< T > |
| Fenwick tree supporting range updates and range queries. More... | |
Namespaces | |
| namespace | Aleph |
| Main namespace for Aleph-w library functions. | |
Concepts | |
| concept | Aleph::FenwickArithmetic |
| Arithmetic domain accepted by Fenwick specializations. | |
| concept | Aleph::FenwickBinaryOp |
| Binary operation compatible with Fenwick tree group functors. | |
Fenwick tree (Binary Indexed Tree) for prefix queries.
A Fenwick tree maintains an implicit array of n elements over an abelian group (an associative, commutative, invertible binary operation with identity) and supports prefix and range queries and point updates in O(log n) time.
Three class templates are provided:
Plus and Minus.operator+ / operator-). Adds the find_kth order-statistic query that exploits the internal bit layout in O(log n).| Operation | Time |
|---|---|
| Construction | O(n) |
| update | O(log n) |
| prefix | O(log n) |
| query | O(log n) |
| find_kth | O(log n) |
| get / set | O(log n) |
| Space | O(n) |
Definition in file tpl_fenwick_tree.H.