|
Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
Heavy Light Decomposition implementation More...
#include <algorithm>#include <cassert>#include <cmath>#include <cstring>#include <iostream>#include <list>#include <numeric>#include <string>#include <vector>Classes | |
| class | range_queries::heavy_light_decomposition::Tree< X > |
| A Basic Tree, which supports binary lifting. More... | |
| class | range_queries::heavy_light_decomposition::SG< X > |
| Segment Tree, to store heavy chains. More... | |
| class | range_queries::heavy_light_decomposition::HLD< X > |
| The Heavy-Light Decomposition class. More... | |
Namespaces | |
| namespace | range_queries |
| Algorithms and Data Structures that support range queries and updates. | |
| namespace | heavy_light_decomposition |
| Heavy light decomposition algorithm. | |
Functions | |
| static void | test_1 () |
| static void | test_2 () |
| static void | test_3 () |
| int | main () |
Heavy Light Decomposition implementation
Heavy-Light Decomposition is a technique on trees, that supports the following:
The update is done in O(log n) time, and the query is done in O(log^2 n) time with HLD where, n is the number of nodes
The template type is the data type of the value stored in the nodes. If a non-primitive data-type is used as a template, the coressponding operators must be overloaded.
An HLD object can only be created with a constant number of nodes, and it cannot be changed later. Creaty an empty instance is not supported.
To start answering updates and queries,
Sample I/O at the bottom.
| int main | ( | void | ) |
|
static |
Test implementations
|
static |
Second test implementations
|
static |
Third test implementations