MCPcopy Create free account
hub / github.com/ShahjalalShohag/code-library / build

Function build

Data Structures/Sparse Table.cpp:7–14  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5
6int t[N][18], a[N];
7void build(int n) {
8 for(int i = 1; i <= n; ++i) t[i][0] = a[i];
9 for(int k = 1; k < 18; ++k) {
10 for(int i = 1; i + (1 << k) - 1 <= n; ++i) {
11 t[i][k] = min(t[i][k - 1], t[i + (1 << (k - 1))][k - 1]);
12 }
13 }
14}
15
16int query(int l, int r) {
17 int k = 31 - __builtin_clz(r - l + 1);

Callers 15

buildMethod · 0.70
buildMethod · 0.70
mainFunction · 0.70
buildMethod · 0.70
buildMethod · 0.70
buildMethod · 0.70
buildMethod · 0.70
buildBetweenZeroMethod · 0.70
buildMethod · 0.70
SqrtTreeMethod · 0.70
buildMethod · 0.70
buildMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected