diff --git a/src/data_structures/segment_tree.md b/src/data_structures/segment_tree.md index 65516fa38..3e4948e8c 100644 --- a/src/data_structures/segment_tree.md +++ b/src/data_structures/segment_tree.md @@ -805,6 +805,17 @@ Before traversing to a child vertex, we call $\text{push}$ and propagate the val We have to do this in both the $\text{update}$ function and the $\text{query}$ function. ```cpp +void build(int a[], int v, int tl, int tr) { + if (tl == tr) { + t[v] = a[tl]; + } else { + int tm = (tl + tr) / 2; + build(a, v*2, tl, tm); + build(a, v*2+1, tm+1, tr); + t[v] = max(t[v*2], t[v*2 + 1]); + } +} + void push(int v) { t[v*2] += lazy[v]; lazy[v*2] += lazy[v]; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy