|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Four creative scenarios demonstrating Segment Tree variants. More...
Go to the source code of this file.
Functions | |
| static void | scenario_1_el_arbol_del_tiempo () |
| static void | scenario_2_ajustes_salariales () |
| static void | scenario_3_balanceo_servidores () |
| static void | scenario_4_rmq_comparison () |
| int | main () |
Four creative scenarios demonstrating Segment Tree variants.
A historian maintains a timeline of the oldest known artifact per century (indices 0..9 represent centuries 1-10). She queries "what is the oldest artifact across centuries 3-7?" and updates individual centuries when new archaeological discoveries push dates further back.
An HR system tracks salaries by department index. Corporate announces range raises ("add $500 to departments 3-7") and the CFO queries "total payroll for departments 2-5". This is the canonical range-update + range-query pattern.
A data center has server racks with varying load. Operations applies chmin (cap load) and chmax (set minimum floor) across rack ranges, then queries total load per section.
Side-by-side comparison showing when to use Sparse Table (static, O(1) query) vs Segment Tree (dynamic, O(log n) query).
Definition in file segment_tree_example.cc.
| int main | ( | ) |
Definition at line 224 of file segment_tree_example.cc.
References scenario_1_el_arbol_del_tiempo(), scenario_2_ajustes_salariales(), scenario_3_balanceo_servidores(), and scenario_4_rmq_comparison().
|
static |
Definition at line 69 of file segment_tree_example.cc.
References Aleph::divide_and_conquer_partition_dp(), and Aleph::Gen_Segment_Tree< T, Op >::get().
Referenced by main().
|
static |
Definition at line 109 of file segment_tree_example.cc.
References Aleph::divide_and_conquer_partition_dp(), and Aleph::Gen_Lazy_Segment_Tree< Policy >::get().
Referenced by main().
|
static |
Definition at line 146 of file segment_tree_example.cc.
References Aleph::divide_and_conquer_partition_dp(), and Aleph::Segment_Tree_Beats< T >::get().
Referenced by main().
|
static |
Definition at line 183 of file segment_tree_example.cc.
References Aleph::divide_and_conquer_partition_dp(), l, and r.
Referenced by main().