diff --git a/d1/d9e/prefix__sum__array_8cpp.html b/d1/d9e/prefix__sum__array_8cpp.html new file mode 100644 index 000000000..c694729a8 --- /dev/null +++ b/d1/d9e/prefix__sum__array_8cpp.html @@ -0,0 +1,321 @@ + + + + + + + +Algorithms_in_C++: range_queries/prefix_sum_array.cpp File Reference + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
Algorithms_in_C++ 1.0.0 +
+
Set of algorithms implemented in C++.
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
prefix_sum_array.cpp File Reference
+
+
+ +

Prefix Sum Array data structure implementation. +More...

+
#include <cassert>
+#include <iostream>
+#include <vector>
+
+Include dependency graph for prefix_sum_array.cpp:
+
+
+
+
+
+ + + + + + + +

+Namespaces

namespace  range_queries
 Algorithms and Data Structures that support range queries and updates.
 
namespace  prefix_sum_array
 Range sum queries using prefix-sum-array.
 
+ + + + + + + + + + + + + +

+Functions

void range_queries::prefix_sum_array::build (std::vector< int64_t > original_array)
 function that builds the PSA More...
 
int64_t range_queries::prefix_sum_array::query (int64_t beg, int64_t end)
 query function More...
 
static void test ()
 Self-test implementations. More...
 
int main ()
 Main function. More...
 
+ + + +

+Variables

+std::vector< int64_t > range_queries::prefix_sum_array::PSA (1, 0)
 
+

Detailed Description

+

Prefix Sum Array data structure implementation.

+

Prefix Sum Array is a data structure, that allows answering sum in some range queries. It can answer most sum range queries in O(1), with a build time complexity of O(N). But it hasn't an update querie.

+ +

Function Documentation

+ +

◆ build()

+ +
+
+ + + + + + + + +
void range_queries::prefix_sum_array::build (std::vector< int64_t > original_array)
+
+ +

function that builds the PSA

+
Parameters
+ + +
original_arrayoriginal array of values
+
+
+
Returns
void
+
41 {
+
42 for (int i = 1; i <= static_cast<int>(original_array.size()); i++) {
+
43 PSA.push_back(PSA[i - 1] + original_array[i]);
+
44 }
+
45}
+
T size(T... args)
+
+Here is the call graph for this function:
+
+
+
+
+ +
+
+ +

◆ main()

+ +
+
+ + + + + + + + +
int main (void )
+
+ +

Main function.

+
Returns
0 on exit
+
80 {
+
81 test(); // run self-test implementations
+
82 return 0;
+
83}
+
static void test()
Self-test implementations.
Definition: prefix_sum_array.cpp:61
+
+Here is the call graph for this function:
+
+
+
+
+ +
+
+ +

◆ query()

+ +
+
+ + + + + + + + + + + + + + + + + + +
int64_t range_queries::prefix_sum_array::query (int64_t beg,
int64_t end 
)
+
+ +

query function

+
Parameters
+ + + +
begbegin of the interval to sum
endend of the interval to sum
+
+
+
Returns
sum of the range [beg, end]
+
52{ return PSA[end] - PSA[beg - 1]; }
+
T end(T... args)
+
+
+
+ +

◆ test()

+ +
+
+ + + + + +
+ + + + + + + +
static void test ()
+
+static
+
+ +

Self-test implementations.

+
Returns
void
+
61 {
+
62 std::vector<int64_t> values{0, 123, 0, 2, -2, 5,
+
63 24, 0, 23, -1, -1}; // original array
+
64
+ +
66 // queries are of the type: sum of the range [a, b] = psa[b] - psa[a-1]
+
67
+
68 assert(range_queries::prefix_sum_array::query(1, 10) ==
+
69 173); // sum of the entire array
+
70 assert(range_queries::prefix_sum_array::query(4, 6) ==
+
71 27); // the sum of the interval [4, 6]
+
72 assert(range_queries::prefix_sum_array::query(5, 9) ==
+
73 51); // the sum of the interval [5, 9]
+
74}
+
void build(std::vector< int64_t > original_array)
function that builds the PSA
Definition: prefix_sum_array.cpp:41
+ +
+
+
+
+
+ + + + diff --git a/d1/d9e/prefix__sum__array_8cpp.js b/d1/d9e/prefix__sum__array_8cpp.js new file mode 100644 index 000000000..add55907d --- /dev/null +++ b/d1/d9e/prefix__sum__array_8cpp.js @@ -0,0 +1,7 @@ +var prefix__sum__array_8cpp = +[ + [ "build", "d1/d9e/prefix__sum__array_8cpp.html#ab36151479ad37d53ef9fcb60a274b1d9", null ], + [ "main", "d1/d9e/prefix__sum__array_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4", null ], + [ "query", "d1/d9e/prefix__sum__array_8cpp.html#a7c8fd967c36dbba5fdf9c71faed604cf", null ], + [ "test", "d1/d9e/prefix__sum__array_8cpp.html#aa8dca7b867074164d5f45b0f3851269d", null ] +]; \ No newline at end of file diff --git a/d1/d9e/prefix__sum__array_8cpp_ab36151479ad37d53ef9fcb60a274b1d9_cgraph.map b/d1/d9e/prefix__sum__array_8cpp_ab36151479ad37d53ef9fcb60a274b1d9_cgraph.map new file mode 100644 index 000000000..fcd4405f2 --- /dev/null +++ b/d1/d9e/prefix__sum__array_8cpp_ab36151479ad37d53ef9fcb60a274b1d9_cgraph.map @@ -0,0 +1,4 @@ + + + + diff --git a/d1/d9e/prefix__sum__array_8cpp_ab36151479ad37d53ef9fcb60a274b1d9_cgraph.md5 b/d1/d9e/prefix__sum__array_8cpp_ab36151479ad37d53ef9fcb60a274b1d9_cgraph.md5 new file mode 100644 index 000000000..a39b537ce --- /dev/null +++ b/d1/d9e/prefix__sum__array_8cpp_ab36151479ad37d53ef9fcb60a274b1d9_cgraph.md5 @@ -0,0 +1 @@ +ba70f334e95d78a9f30fc3c0388e8f4c \ No newline at end of file diff --git a/d1/d9e/prefix__sum__array_8cpp_ab36151479ad37d53ef9fcb60a274b1d9_cgraph.svg b/d1/d9e/prefix__sum__array_8cpp_ab36151479ad37d53ef9fcb60a274b1d9_cgraph.svg new file mode 100644 index 000000000..09ac87344 --- /dev/null +++ b/d1/d9e/prefix__sum__array_8cpp_ab36151479ad37d53ef9fcb60a274b1d9_cgraph.svg @@ -0,0 +1,44 @@ + + + + + + +range_queries::prefix_sum_array::build + + + +Node1 + + +range_queries::prefix +_sum_array::build + + + + + +Node1->Node1 + + + + + +Node2 + + +std::vector::size + + + + + +Node1->Node2 + + + + + diff --git a/d1/d9e/prefix__sum__array_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map b/d1/d9e/prefix__sum__array_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map new file mode 100644 index 000000000..d700ab878 --- /dev/null +++ b/d1/d9e/prefix__sum__array_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map @@ -0,0 +1,4 @@ + + + + diff --git a/d1/d9e/prefix__sum__array_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 b/d1/d9e/prefix__sum__array_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 new file mode 100644 index 000000000..f93ad06ff --- /dev/null +++ b/d1/d9e/prefix__sum__array_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 @@ -0,0 +1 @@ +a0f50f064e17dc3de597c81c20292210 \ No newline at end of file diff --git a/d1/d9e/prefix__sum__array_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg b/d1/d9e/prefix__sum__array_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg new file mode 100644 index 000000000..8ddae4d58 --- /dev/null +++ b/d1/d9e/prefix__sum__array_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg @@ -0,0 +1,37 @@ + + + + + + +main + + + +Node1 + + +main + + + + + +Node2 + + +test + + + + + +Node1->Node2 + + + + + diff --git a/d2/d76/prefix__sum__array_8cpp__incl.map b/d2/d76/prefix__sum__array_8cpp__incl.map new file mode 100644 index 000000000..d8eb0f5ca --- /dev/null +++ b/d2/d76/prefix__sum__array_8cpp__incl.map @@ -0,0 +1,6 @@ + + + + + + diff --git a/d2/d76/prefix__sum__array_8cpp__incl.md5 b/d2/d76/prefix__sum__array_8cpp__incl.md5 new file mode 100644 index 000000000..f1454265c --- /dev/null +++ b/d2/d76/prefix__sum__array_8cpp__incl.md5 @@ -0,0 +1 @@ +485d227d1f62e886f8a38a7d5b98b906 \ No newline at end of file diff --git a/d2/d76/prefix__sum__array_8cpp__incl.svg b/d2/d76/prefix__sum__array_8cpp__incl.svg new file mode 100644 index 000000000..9e162d98e --- /dev/null +++ b/d2/d76/prefix__sum__array_8cpp__incl.svg @@ -0,0 +1,68 @@ + + + + + + +range_queries/prefix_sum_array.cpp + + + +Node1 + + +range_queries/prefix +_sum_array.cpp + + + + + +Node2 + + +cassert + + + + + +Node1->Node2 + + + + + +Node3 + + +iostream + + + + + +Node1->Node3 + + + + + +Node4 + + +vector + + + + + +Node1->Node4 + + + + + diff --git a/d5/d88/md__d_i_r_e_c_t_o_r_y.html b/d5/d88/md__d_i_r_e_c_t_o_r_y.html index 701ec742d..514ce65b3 100644 --- a/d5/d88/md__d_i_r_e_c_t_o_r_y.html +++ b/d5/d88/md__d_i_r_e_c_t_o_r_y.html @@ -408,6 +408,7 @@ Range Queries
  • Heavy Light Decomposition
  • Mo
  • Persistent Seg Tree Lazy Prop
  • +
  • Prefix Sum Array
  • Segtree
  • Sparse Table
  • diff --git a/d7/d88/namespaceprefix__sum__array.html b/d7/d88/namespaceprefix__sum__array.html new file mode 100644 index 000000000..6ee0b5d1b --- /dev/null +++ b/d7/d88/namespaceprefix__sum__array.html @@ -0,0 +1,111 @@ + + + + + + + +Algorithms_in_C++: prefix_sum_array Namespace Reference + + + + + + + + + + + + + + + +
    +
    + + + + + + +
    +
    Algorithms_in_C++ 1.0.0 +
    +
    Set of algorithms implemented in C++.
    +
    +
    + + + + + + + +
    +
    + +
    +
    +
    + +
    + +
    +
    + + +
    + +
    + +
    +
    prefix_sum_array Namespace Reference
    +
    +
    + +

    Range sum queries using prefix-sum-array. +More...

    +

    Detailed Description

    +

    Range sum queries using prefix-sum-array.

    +
    +
    + + + + diff --git a/dd/d69/namespacerange__queries.html b/dd/d69/namespacerange__queries.html index 9ac2f7c6b..46693edf5 100644 --- a/dd/d69/namespacerange__queries.html +++ b/dd/d69/namespacerange__queries.html @@ -108,8 +108,11 @@ Classes

    Detailed Description

    Algorithms and Data Structures that support range queries and updates.

    Range Queries algorithms.

    +

    for std::vector

    Range queries algorithms.

    -

    for IO operations to manage dynamic memory for std::vector

    +

    for IO operations to manage dynamic memory for std::vector

    +

    for assert for IO operations

    +

    Range Queries algorithms

    diff --git a/dd/d69/namespacerange__queries.js b/dd/d69/namespacerange__queries.js index b67ae91f1..e123132ca 100644 --- a/dd/d69/namespacerange__queries.js +++ b/dd/d69/namespacerange__queries.js @@ -5,6 +5,10 @@ var namespacerange__queries = [ "SG", "d9/d35/classrange__queries_1_1heavy__light__decomposition_1_1_s_g.html", "d9/d35/classrange__queries_1_1heavy__light__decomposition_1_1_s_g" ], [ "Tree", "d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html", "d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree" ] ] ], + [ "prefix_sum_array", null, [ + [ "build", "d1/d9e/prefix__sum__array_8cpp.html#ab36151479ad37d53ef9fcb60a274b1d9", null ], + [ "query", "d1/d9e/prefix__sum__array_8cpp.html#a7c8fd967c36dbba5fdf9c71faed604cf", null ] + ] ], [ "sparse_table", null, [ [ "buildTable", "d4/d96/range__queries_2sparse__table_8cpp.html#a803a2451e87021d14ae06f148383e6bc", null ], [ "computeLogs", "d4/d96/range__queries_2sparse__table_8cpp.html#a40810d8c0fe3f8cf432ab128b1ae0300", null ], diff --git a/dir_074119ce3a874b57120c49a0cc4bb5ad.html b/dir_074119ce3a874b57120c49a0cc4bb5ad.html index cd116c4c7..512417aff 100644 --- a/dir_074119ce3a874b57120c49a0cc4bb5ad.html +++ b/dir_074119ce3a874b57120c49a0cc4bb5ad.html @@ -105,6 +105,9 @@ Files file  persistent_seg_tree_lazy_prop.cpp  Persistent segment tree with range updates (lazy propagation)
      +file  prefix_sum_array.cppPrefix Sum Array data structure implementation.
    +  file  sparse_table.cpp  Implementation of Sparse Table data structure.
      diff --git a/dir_074119ce3a874b57120c49a0cc4bb5ad.js b/dir_074119ce3a874b57120c49a0cc4bb5ad.js index f4ee6638d..a3d83df29 100644 --- a/dir_074119ce3a874b57120c49a0cc4bb5ad.js +++ b/dir_074119ce3a874b57120c49a0cc4bb5ad.js @@ -3,5 +3,6 @@ var dir_074119ce3a874b57120c49a0cc4bb5ad = [ "fenwick_tree.cpp", "d6/d2e/fenwick__tree_8cpp.html", "d6/d2e/fenwick__tree_8cpp" ], [ "heavy_light_decomposition.cpp", "d2/de9/heavy__light__decomposition_8cpp.html", "d2/de9/heavy__light__decomposition_8cpp" ], [ "persistent_seg_tree_lazy_prop.cpp", "d5/d58/persistent__seg__tree__lazy__prop_8cpp.html", "d5/d58/persistent__seg__tree__lazy__prop_8cpp" ], + [ "prefix_sum_array.cpp", "d1/d9e/prefix__sum__array_8cpp.html", "d1/d9e/prefix__sum__array_8cpp" ], [ "sparse_table.cpp", "d4/d96/range__queries_2sparse__table_8cpp.html", "d4/d96/range__queries_2sparse__table_8cpp" ] ]; \ No newline at end of file diff --git a/files.html b/files.html index ce47805d5..d3fdd7b77 100644 --- a/files.html +++ b/files.html @@ -298,7 +298,8 @@ solve-a-rat-in-a-maze-c-java-pytho/"  fenwick_tree.cppFenwick tree  heavy_light_decomposition.cppHeavy Light Decomposition implementation  persistent_seg_tree_lazy_prop.cppPersistent segment tree with range updates (lazy propagation) - sparse_table.cppImplementation of Sparse Table data structure + prefix_sum_array.cppPrefix Sum Array data structure implementation + sparse_table.cppImplementation of Sparse Table data structure   search  binary_search.cppBinary search algorithm  exponential_search.cppExponential search algorithm diff --git a/globals_func_m.html b/globals_func_m.html index 568dd0617..d58fdf390 100644 --- a/globals_func_m.html +++ b/globals_func_m.html @@ -93,7 +93,7 @@ $(document).ready(function(){initNavTree('globals_func_m.html',''); initResizabl  

    - m -